vendredi 24 janvier 2020

SAS conditional IF-THEN statement not working

I am a beginner user of SAS and currently, I'm following one of the Coursera courses. The code given in a lecture doesn't work although I don't see an error. Below the code:

PROC IMPORT DATAFILE ='/home/student123/my_courses/nesarc_pds.csv' OUT = data  REPLACE;

LABEL TAB12MDX ="Tobacco Dependance Past 12 Months"
      CHECK321 ="Smoked Cigarettes in Past 12 Months"
      S3AQ3B1 ="Usual Smoking Frequency"
      S3AQ3C1 ="Usual Smoking Quantity";

IF S3AQ3B1=9 THEN S3AQ3B1=.;
IF S3AQ3C1=99 THEN S3AQ3C1=.;
IF CHECK321=1;
IF AGE LE 25;
PROC SORT; BY IDNUM;
PROC FREQ; TABLES TAB12MDX CHECK321 S3AQ3B1 S3AQ3C1 AGE;
RUN;

The error I see in a log is:

80         IF S3AQ3B1=9 THEN S3AQ3B1=MISSING;
        __
        180
81         IF CHECK321=1;
        __
        180
82         IF AGE LE 25;
        __
        180
ERROR 180-322: Statement is not valid or it is used out of proper order.

I use SAS Studio but I don't know does it matter.

Does anyone know where is an error?

Aucun commentaire:

Enregistrer un commentaire