Hi,
Not sure if I'm writing the code correcly, even if I am, the second macro call is not being called and outputting the same results as the first macro. I think the issue might have to do with cedpld.
%macro test(blind=,cedpld =);
proc sort data = adam.adce out = adce ;
by usubjid;
where saffl='Y' and cedplddy=2 and &cedpld ;
run;
%if &blind=Y %then %do;
data qc.ds_Blind ;
set final;
run;
%end;
%if &blind=N %then %do;
data qc.ds_Unblind ;
set final;
run;
%end;
%mend;
%test(blind=Y, cedpld= 0<=cedpld>=14) ;
%test(blind=N, cedpld= 0<=cedpld<14) ;
... the second macro call is not being called and outputting the same results ...
We don't know what this means.
First, run this command to turn on a useful macro debugging tool.
options mprint;
Then run the code again and show us the log for your code (all of it, every single character, do not chop parts out) by copying the log as text and pasting it into the window that appears when you click on the </> icon. DO NOT SKIP THIS STEP.
From now on, when code isn't working, you need to show us the LOG as described above, don't wait for us to ask.
Your first macro call contains this parameter value:
cedpld= 0<=cedpld>=14
This is probably not the right logic. It means:
(0<=cedpld) and (cedpld >=14)
So at a bare minimum, the first comparison (comparing to zero) is not needed and is included by the second comparison. More likely, though, the logic of the comparisons is not correct.
Take the PROC SORT out of the macro and hard code the values.
Then run it for each case, and check you're getting the results you expect
proc sort data = adam.adce out = adce_c1 ;
by usubjid;
where saffl='Y' and cedplddy=2 and 0<=cedpld>=14 ;
run;
proc sort data = adam.adce out = adce_c2 ;
by usubjid;
where saffl='Y' and cedplddy=2 and 0<=cedpld<14 ;
run;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.