have to dipslay the datasets starting with name P
proc sql;
select distinct memname into : ab separated by ',' from
dictionary.columns where libname='work' and upcase(memname) like"P%";
%let r=&sqlobs;
quit;
%put &ab &r;
(P1,PATIENT,PAWAN,PAWAN1,PP,PULMICORT_PA,PULMICORT_PH 7)
%macro b(libname);
%do i= 1 %to &r;
proc print data=&libname..%scan(&ab,&i);
run;
%end;
%mend;
%b(work);
getting error -
ERROR: Macro function %SCAN has too many arguments. The excess arguments will be ignored.
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand
is required. The condition was: PATIENT
ERROR: Argument 2 to macro function %SCAN is not a number
If a macro variable parameter has comma's how does SAS know which is part of the macro %scan, and which is part of the macro variable. Try using a different delimiter for your macro variable list.
It is a job interview question for some CRO corporation ?
%macro b(libname);
data _null_;
set sashelp.vmember(where=(libname="%upcase(&libname)" and upcase(memname) like "P%"));
call execute(cats('proc print data=',libname,'.',memname,';run;'));
run;
%mend;
%b(work)
%macro b(libname);
data _null_;
set sashelp.vmember(where=(libname="%upcase(&libname)" and upcase(memname) like "P%" and memtype='DATA'));
call execute(cats('proc print data=',libname,'.',memname,';run;'));
run;
%mend;
%b(work)
Updated
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.