BookmarkSubscribeRSS Feed
Ronein
Onyx | Level 15

Hello

I want to create a new data set by set multiple data sets that appear in  another data set.

For example:

in data set "helptbl" we can see the names of the data sets that will be in SET statement.

What is the way to tell SAS to using these name for SET statement (without doing it manually...)

 

data helptbl;
input tblnames;
cards;
tbl190828
tbl190825
tbl190821
tbl190812
tbl190803
;
run;


Data tbl_all;
set tbl190828
tbl190825
tbl190821
tbl190812
tbl190803
;
run;
3 REPLIES 3
Coooooo_Lee
Obsidian | Level 7
data helptbl;
input tblnames $9.;
cards;
tbl190828
tbl190825
tbl190821
tbl190812
tbl190803
;
run;

proc sql noprint;
  select tblnames into :tname separated by ' ' from helptbl;
quit;

Data tbl_all;
set &tname.;
run;
ed_sas_member
Meteorite | Level 14

Hi @Ronein 

 

If you want to append all the datasets beginning by "tbl" of a library, you can directly do this by using the following code :

 

data want;
	set tbl:;
run;

Otherwise, if you want to append only some of these datasets (which are listed in the helptbl dataset), the solution provided by @Coooooo_Lee would work.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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
  • 3 replies
  • 857 views
  • 0 likes
  • 4 in conversation