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
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.