BookmarkSubscribeRSS Feed
HitmonTran
Pyrite | Level 9

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) ;

 

3 REPLIES 3
PaigeMiller
Diamond | Level 26

... 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.

 

2021-11-26 08_27_29-Reply to Message - SAS Support Communities — Mozilla Firefox.png

 

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.

--
Paige Miller
Astounding
PROC Star

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.

AMSAS
SAS Super FREQ

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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 520 views
  • 1 like
  • 4 in conversation