BookmarkSubscribeRSS Feed
Lakshmisas
Calcite | Level 5

options minoperator mlogic;

%macro test(value)/mindelimiter=',';
Data _Null_;
CALL SYMPUT('Vendor',2);
run;

%DO I=1 %TO &Vendor; /* LOOP THRU ALL Vendors */
%PUT *** LOOP &I OF &Vendor;

%if &value&I in Hari RRR,John yy,Peter,Jai,Phano %then

%put Value found within list.;

%else %put Value not in list.;
%end;

%mend;
%test(Hari RRR);

3 REPLIES 3
novinosrin
Tourmaline | Level 20

Correction

 

options minoperator;
%macro test(value)/mindelimiter=',';
Data _Null_;
CALL SYMPUT('Vendor',2);
run;

%DO I=1 %TO &Vendor; /* LOOP THRU ALL Vendors */
%PUT *** LOOP &I OF &Vendor;
%if &value in (Hari RRR,John yy,Peter,Jai,Phano )%then

%put Value found within list.;

%else %put Value not in list.;
%end;

%mend;
%test(Hari RRR)

You don't need suffix &i in &value&I coz macro parameter value is the name of the macro var and the value is Hari RRR. You do not have a series here.

andreas_lds
Jade | Level 19
Why do you have data in macro-variables?
Astounding
PROC Star

While you have received a good suggestion, the context is wrong.

 

You should use &VALUE, not &VALUE&I:

 

%if &value in ........;

 

However, do NOT add parentheses around your existing list of values.  The corrected version would simply be:

 

%if &value in Hari RRR,John yy,Peter,Jai,Phano %then

%put Value found within list.;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

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
  • 788 views
  • 0 likes
  • 4 in conversation