Hello,
%macro tab(mem=);
%global table1 ;
%let table1=;
%local table;
%let table=;
%let dsid = %sysfunc(open(&mem.,in));
%let nbr = %sysfunc(attrn(&dsid,nobs));
%if &nbr.=0 %THEN %do;
%let table =&mem.;
%let table1=%sysfunc(catx('-',&table,&table1));
%end;
%if &dsid. > 0 %then
%let rc = %sysfunc(close(&dsid));
%mend tab;
DATA _null_;
SET vcol;
call execute('%tab(mem='||strip(memname)||');');
run;
%Put table1=&table1;
unable to add the missing code to my last post, so here it is:
proc sql noprint; select MemName into :table1 separated by '-' from sashelp.vtable where nobs = 0 and MemName in ( select MemName from work.vcol ) ; quit; %put &=table1;
%let table1=&table.-&table1;
instead of
%let table1=%sysfunc(catx('-',&table,&table1));
You reset &table1 each time the macro is called
%let table1=;
To solve this remove
%global table1 ;
%let table1=;
from the macro and put them before the data-step.
Even better: use dictionary.tables, as suggested by @Kurt_Bremser.
The following code is untested, because i don't know what you have in dataset "vcol":
unable to add the missing code to my last post, so here it is:
proc sql noprint; select MemName into :table1 separated by '-' from sashelp.vtable where nobs = 0 and MemName in ( select MemName from work.vcol ) ; quit; %put &=table1;
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.