Suppose the following:
data concatenation;
set animal plant;
run;
Given a long list of SAS data sets, I would prefer to use a "data set list". Apparently in order to do so, the data sets have to begin with the same character.
Example: set library.a: ;
Suppose all data sets have different starting characters. And I'd rather not rename them all, so as to have a common first character.
Combine (stack, concatenate) ALL the data sets in this particular 'library', please....
Suggestions or thoughts greatly appreciated.
Is there a Proc SQL equivalent that I could use?
Thanks!
Nicholas Kormanik
Hi @NKormanik
You can get the dataset names from sashelp.vtable. Get all names within the wanted library in a data step and use the list to create another data step and execute it. Following code is tested and works as expected.
%let inlibref = work;
%let concatds = work.all;
data _null_;
set sashelp.vtable (where=(libname=upcase("&libref"))) end=eod;
length str $32000;
retain str "data &concatds; set";
str = catx(' ',str,memname);
if eod then do;
str = catx(' ',str,'; run;');
call execute(str);
end;
run;
Use proc sql select into from dictionary.tables:
proc sql noprint;
select memname into : dslist separated by ' '
from dictionary.tables
where libname = "YOURLIB"; /* capitals here! */
quit;
data want;
set &dslist.;
run;
Hi @NKormanik
You can get the dataset names from sashelp.vtable. Get all names within the wanted library in a data step and use the list to create another data step and execute it. Following code is tested and works as expected.
%let inlibref = work;
%let concatds = work.all;
data _null_;
set sashelp.vtable (where=(libname=upcase("&libref"))) end=eod;
length str $32000;
retain str "data &concatds; set";
str = catx(' ',str,memname);
if eod then do;
str = catx(' ',str,'; run;');
call execute(str);
end;
run;
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 save with the early bird rate—just $795!
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.