BookmarkSubscribeRSS Feed
Ronein
Meteorite | Level 14

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.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 357 views
  • 0 likes
  • 4 in conversation