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

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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