DATA Step, Macro, Functions and more

macro comparison operator

Reply
Super Contributor
Posts: 291

macro comparison operator

The first macro pgm does not work in SAS 9.1.3. An alternative is to use the second one, however, I'd rather not repeat the "proc print data=test;run;" section since it's actually very long in my pgm. Perhaps I'm having a brain cramp, but I haven't been able to come up with an alternative. Can someone help? (&runflg comes in from another part of the pgm). Thanks, Bill

%macro report; %*First;

%if &runflg in 1,5 %then %do;
proc print
data=test;
run;
%end;

%mend report;
%report;



%macro report;%*Second;


%if &runflg = 1 %then %do;
proc print data=test;
run;
%end;

%else %if &runflg = 5 %then %do;
proc print data=test;
run;
%end;

%mend report;
%report; changed %runflg to &runflg

Message was edited by: Bill
Valued Guide
Posts: 2,177

Re: macro comparison operator

of course the OR logic would provide a substitute for IN
However, IN should be working..... if you set system option different from the default NOmInOperator ;-)
Try
%put abc = %eval( 1 in 1 2 3 ) ;
%put def = %eval( 1 in 1,2, 3 ) ;

If you want to use a comma separator for the IN list, then set option mInDeliminator

Good Luck
PeterC
N/A
Posts: 0

Re: macro comparison operator

sorry,
that last posting was using options from SAS9.2
which introduces the IN operator to the SAS Macro language.

For SAS 9.1.3 you need to create your own, or use OR, like [pre]
%if &runflg = 1 OR &runflg =5 %then %do;
[/pre]
Good Luck

PeterC
Super Contributor
Posts: 291

Re: macro comparison operator

Posted in reply to deleted_user
Thank you Peter.

How odd (to me at least) that it's not %OR.

wd
N/A
Posts: 0

Re: macro comparison operator

Posted in reply to deleted_user
Hi,
i tried to use IN but it does not work (lvl 9.1.3) and reading you messages it works from 9.2 explains a lot
BUT read the sas help: http://support.sas.com/onlinedoc/913/getDoc/nl/mcrolref.hlp/a002475219.htm

Here it says it should work from level 9 !!!

GreetZ,
Herman
Super User
Posts: 5,426

Re: macro comparison operator

Posted in reply to deleted_user
Here's the explanation for that:

http://support.sas.com/kb/11/945.html

/Linus
Data never sleeps
Ask a Question
Discussion stats
  • 5 replies
  • 216 views
  • 0 likes
  • 4 in conversation