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;
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.