Dear all, thank you so much for your advices. The program is when I adding the other parts, the error showing up. It skip two %if condition to run the programs after two %if condition , then coming back to run %if condition, however, I want %if condition run first, then run the rest program: %macro demo( linenumber ,indsn , agevar, outdsn ) ; %if &linenumber. =0 %then %do ; data demo; set &indsn.; yearmet = year(MetDiagnosisDate); age = year(&agevar.) - birthyear; run; %let var = yearmet gender age weight0 PracticeType LLY_region Race ecog0 GroupStage ER PR HER2; %end; %if &linenumber. = 1 %then %do; data demo; set &indsn.; yearmet = year(MetDiagnosisDate); age = year(&agevar.) - birthyear; run; %let var = yearmet gender age weight1 PracticeType LLY_region Race ecog1 GroupStage ER PR HER2; %end; data demog; length cohort $30; set demo(in=a) demo(in=b) demo(where=(HR='positive' and her2='negative') in=c) demo(where=(HR='positive' and her2='positive') in=d) demo(where=(HR='negative' and her2='negative') in=e) demo(where=(HR='negative' and her2='positive') in=f) ; if a then cohort = 'overall'; if b then cohort = put(treat, 1.); if c then cohort = 'subtypeA'; if d then cohort = 'subtypeB'; if e then cohort = 'subtypeC'; if f then cohort = 'subtypeD'; run; %mend; %demo; %demo( linenumber=0 ,indsn=ads.ads , agevar = MetDiagnosisDate, outdsn = demog0 ) ; NOTE: Writing HTML(EGHTML) Body file: EGHTML 23 24 GOPTIONS ACCESSIBLE; 25 option mprint mlogic; 26 27 %macro demo( linenumber ,indsn , agevar, outdsn ) ; 28 29 %if &linenumber. = 0 %then %do ; 30 data demo; 31 set &indsn.; 32 yearmet = year(MetDiagnosisDate); 33 age = year(&agevar.) - birthyear; 34 run; 35 %let var = yearmet gender age weight0 PracticeType LLY_region Race ecog0 GroupStage ER PR HER2; 36 %end; 37 38 %if &linenumber. = 1 %then %do; 39 data demo; 40 set &indsn.; 41 yearmet = year(MetDiagnosisDate); 42 age = year(&agevar.) - birthyear; 43 run; 44 %let var = yearmet gender age weight1 PracticeType LLY_region Race ecog1 GroupStage ER PR HER2; 45 %end; 46 47 data demog; 48 length cohort $30; 49 set demo(in=a) 50 demo(in=b) 51 demo(where=(HR='positive' and her2='negative') in=c) 52 demo(where=(HR='positive' and her2='positive') in=d) 53 demo(where=(HR='negative' and her2='negative') in=e) 54 demo(where=(HR='negative' and her2='positive') in=f) ; 55 if a then cohort = 'overall'; 56 if b then cohort = put(treat, 1.); 57 if c then cohort = 'subtypeA'; 2 The SAS System 58 if d then cohort = 'subtypeB'; 59 if e then cohort = 'subtypeC'; 60 if f then cohort = 'subtypeD'; 61 run; 62 63 64 65 %mend; 66 67 %demo; MLOGIC(DEMO): Beginning execution. MLOGIC(DEMO): Parameter LINENUMBER has value MLOGIC(DEMO): Parameter INDSN has value MLOGIC(DEMO): Parameter AGEVAR has value MLOGIC(DEMO): Parameter OUTDSN has value MLOGIC(DEMO): %IF condition &linenumber. = 0 is FALSE MLOGIC(DEMO): %IF condition &linenumber. = 1 is FALSE MPRINT(DEMO): data demog; MPRINT(DEMO): length cohort $30; MPRINT(DEMO): set demo(in=a) demo(in=b) demo(where=(HR='positive' and her2='negative') in=c) demo(where=(HR='positive' and her2='positive') in=d) demo(where=(HR='negative' and her2='negative') in=e) demo(where=(HR='negative' and her2='positive') in=f) ; ERROR: File WORK.DEMO.DATA does not exist. ERROR: File WORK.DEMO.DATA does not exist. ERROR: File WORK.DEMO.DATA does not exist. ERROR: File WORK.DEMO.DATA does not exist. ERROR: File WORK.DEMO.DATA does not exist. ERROR: File WORK.DEMO.DATA does not exist. MPRINT(DEMO): if a then cohort = 'overall'; MPRINT(DEMO): if b then cohort = put(treat, 1.); MPRINT(DEMO): if c then cohort = 'subtypeA'; MPRINT(DEMO): if d then cohort = 'subtypeB'; MPRINT(DEMO): if e then cohort = 'subtypeC'; MPRINT(DEMO): if f then cohort = 'subtypeD'; MPRINT(DEMO): run; NOTE: The SAS System stopped processing this step because of errors. WARNING: The data set WORK.DEMOG may be incomplete. When this step was stopped there were 0 observations and 2 variables. NOTE: DATA statement used (Total process time): real time 0.00 seconds cpu time 0.01 seconds MLOGIC(DEMO): Ending execution. 68 69 70 %demo( linenumber= 0 ,indsn=ads.ads , agevar = MetDiagnosisDate, outdsn = demog0 ) ; MLOGIC(DEMO): Beginning execution. MLOGIC(DEMO): Parameter LINENUMBER has value 0 MLOGIC(DEMO): Parameter INDSN has value ads.ads MLOGIC(DEMO): Parameter AGEVAR has value MetDiagnosisDate MLOGIC(DEMO): Parameter OUTDSN has value demog0 MLOGIC(DEMO): %IF condition &linenumber. = 0 is TRUE MPRINT(DEMO): data demo; MPRINT(DEMO): set ads.ads; MPRINT(DEMO): yearmet = year(MetDiagnosisDate); MPRINT(DEMO): age = year(MetDiagnosisDate) - birthyear; MPRINT(DEMO): run; 3 The SAS System NOTE: There were 9841 observations read from the data set ADS.ADS. NOTE: The data set WORK.DEMO has 9841 observations and 46 variables. NOTE: DATA statement used (Total process time): real time 0.02 seconds cpu time 0.02 seconds MLOGIC(DEMO): %LET (variable name is VAR) MLOGIC(DEMO): %IF condition &linenumber. = 1 is FALSE MPRINT(DEMO): data demog; MPRINT(DEMO): length cohort $30; MPRINT(DEMO): set demo(in=a) demo(in=b) demo(where=(HR='positive' and her2='negative') in=c) demo(where=(HR='positive' and her2='positive') in=d) demo(where=(HR='negative' and her2='negative') in=e) demo(where=(HR='negative' and her2='positive') in=f) ; MPRINT(DEMO): if a then cohort = 'overall'; MPRINT(DEMO): if b then cohort = put(treat, 1.); MPRINT(DEMO): if c then cohort = 'subtypeA'; MPRINT(DEMO): if d then cohort = 'subtypeB'; MPRINT(DEMO): if e then cohort = 'subtypeC'; MPRINT(DEMO): if f then cohort = 'subtypeD'; MPRINT(DEMO): run; NOTE: There were 9841 observations read from the data set WORK.DEMO. NOTE: There were 9841 observations read from the data set WORK.DEMO. NOTE: There were 5467 observations read from the data set WORK.DEMO. WHERE (HR='positive') and (her2='negative'); NOTE: There were 458 observations read from the data set WORK.DEMO. WHERE (HR='positive') and (her2='positive'); NOTE: There were 1775 observations read from the data set WORK.DEMO. WHERE (HR='negative') and (her2='negative'); NOTE: There were 354 observations read from the data set WORK.DEMO. WHERE (HR='negative') and (her2='positive'); NOTE: The data set WORK.DEMOG has 27736 observations and 47 variables. NOTE: DATA statement used (Total process time): real time 0.05 seconds cpu time 0.05 seconds
... View more