BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
NKormanik
Barite | Level 11

 

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

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
ErikLund_Jensen
Rhodochrosite | Level 12

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;

View solution in original post

2 REPLIES 2
Kurt_Bremser
Super User

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;
ErikLund_Jensen
Rhodochrosite | Level 12

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;

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

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!

Register now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 898 views
  • 3 likes
  • 3 in conversation