Hi @Tom thanks a lot for the explanations in your thread, I'll take more time to practice those techniques. I have tried the usage of minoperator together with mindelimiter for a &list of values separated by commas. The code and results are as follows, this is also a handy and simple usage I think.
%macro customerlist(ctry)/minoperator mindelimiter=',';
proc sql noprint;
select distinct country
into :ctrylist separated by ","
from mc1.customers;
quit;
%if %superq(ctry) in %superq(ctrylist) %then %do;
title "customers from &ctry";
proc sgplot data=mc1.customers;
vbar group;
yaxis grid;
where country="&ctry";
run;
%end;
%else %do;
%put ERROR: &ctry is an invalid country code.;
%put ERROR: Valid country codes include &ctrylist..;
%end;
%mend customerlist;
options symbolgen mprint mlogic;
%customerlist(AU);
%customerlist(zz);
options nosymbolgen nomprint nomlogic;
69 %macro customerlist(ctry)/minoperator mindelimiter=',';
70 proc sql noprint;
71 select distinct country
72 into :ctrylist separated by ","
73 from mc1.customers;
74 quit;
75 %if %superq(ctry) in %superq(ctrylist) %then %do;
76 title "customers from &ctry";
77 proc sgplot data=mc1.customers;
78 vbar group;
79 yaxis grid;
80 where country="&ctry";
81 run;
82 %end;
83 %else %do;
84 %put ERROR: &ctry is an invalid country code.;
85 %put ERROR: Valid country codes include &ctrylist..;
86 %end;
87 %mend customerlist;
88 options symbolgen mprint mlogic;
89 %customerlist(AU);
MLOGIC(CUSTOMERLIST): Beginning execution.
MLOGIC(CUSTOMERLIST): Parameter CTRY has value AU
MPRINT(CUSTOMERLIST): proc sql noprint;
MPRINT(CUSTOMERLIST): select distinct country into :ctrylist separated by "," from mc1.customers;
MPRINT(CUSTOMERLIST): quit;
MLOGIC(CUSTOMERLIST): %IF condition %superq(ctry) in %superq(ctrylist) is TRUE
SYMBOLGEN: Macro variable CTRY resolves to AU
MPRINT(CUSTOMERLIST): title "customers from AU";
MPRINT(CUSTOMERLIST): proc sgplot data=mc1.customers;
MPRINT(CUSTOMERLIST): vbar group;
MPRINT(CUSTOMERLIST): yaxis grid;
SYMBOLGEN: Macro variable CTRY resolves to AU
MPRINT(CUSTOMERLIST): where country="AU";
MPRINT(CUSTOMERLIST): run;
NOTE: PROCEDURE SGPLOT used (Total process time):
NOTE: There were 90 observations read from the data set MC1.CUSTOMERS.
WHERE country='AU';
MLOGIC(CUSTOMERLIST): Ending execution.
90 %customerlist(zz);
MLOGIC(CUSTOMERLIST): Beginning execution.
MLOGIC(CUSTOMERLIST): Parameter CTRY has value zz
MPRINT(CUSTOMERLIST): proc sql noprint;
MPRINT(CUSTOMERLIST): select distinct country into :ctrylist separated by "," from mc1.customers;
MPRINT(CUSTOMERLIST): quit;
MLOGIC(CUSTOMERLIST): %IF condition %superq(ctry) in %superq(ctrylist) is FALSE
MLOGIC(CUSTOMERLIST): %PUT ERROR: &ctry is an invalid country code.
SYMBOLGEN: Macro variable CTRY resolves to zz
ERROR: zz is an invalid country code.
MLOGIC(CUSTOMERLIST): %PUT ERROR: Valid country codes include &ctrylist..
SYMBOLGEN: Macro variable CTRYLIST resolves to
AT,AU,BE,CA,CH,CI,DE,DK,EG,ES,FI,FR,GB,GR,HR,IE,IL,IN,IT,LT,LU,MZ,NL,NO,NZ,PL,PT,SE,SI,TR, US,YU,ZA
ERROR: Valid country codes include
AT,AU,BE,CA,CH,CI,DE,DK,EG,ES,FI,FR,GB,GR,HR,IE,IL,IN,IT,LT,LU,MZ,NL,NO,NZ,PL,PT,SE,SI,TR,US,YU,ZA.
MLOGIC(CUSTOMERLIST): Ending execution.
91 options nosymbolgen nomprint nomlogic;
... View more