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

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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