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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.