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);
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.
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.;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.