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

Hello,

 

I have n tables (>50) with the same variable names, and want to add them after another.

 

I want this result:

Xiple_Dataset_Fusion2.PNG

what should I do?

 

thanks in advance,

PY

 

1 ACCEPTED SOLUTION
6 REPLIES 6
PierreYvesILY
Pyrite | Level 9

hello,

thanks.

 

This is the methods I use, but I hoped there would be something more practical to avoid typing all tables names - and that I would just not be aware of.

 

Have a nice day,

PY

Kurt_Bremser
Super User

If the tables share a common prefix, you can use the colon wildcard; or if you have any other rule, you can use a select into from dictionary.tables to create a macro variable that holds the table names for the set statement.

PierreYvesILY
Pyrite | Level 9

thank you.

 

I would need an example to understand how to use this.

 

Let's say all tables have the following name, ending with a number from 1 to n:

Prod_Week_1 to Prod_Week_n

 

I guess I now have to write :

Prod_Week_:

into the code.

 

data want;

set Prod_Week_: ;

run;

 

Is this correct?

 

the second proposed solution seems more complicated to me (I'm new to SAS), and I don't understand how to write this down in the code.

 

regards,

PY

 

 

 

Kurt_Bremser
Super User

#1 is exactly what I was hinting at with wildcards.

 

#2 will look like this:

proc sql noprint; /* we don't need print output */
select catx('.',libname,memname) into :dsnames separated by ' '
from dictionary.tables
where libname = "XXXX" and /* add further suitable conditions here */
;
quit;

data want;
set &dsnames.;
run; 
PierreYvesILY
Pyrite | Level 9

Thanks a lot.

 

I'll be able to process the 52 files tomorrow now...

 

Have a nice evening,

PY

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 6 replies
  • 471 views
  • 3 likes
  • 2 in conversation