Hello,
I have n tables (>50) with the same variable names, and want to add them after another.
I want this result:
what should I do?
thanks in advance,
PY
Use them in a single set statement, in the wanted order:
data want;
set
set1
set2
....
set50
;
run;
Use them in a single set statement, in the wanted order:
data want;
set
set1
set2
....
set50
;
run;
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
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.
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
#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;
Thanks a lot.
I'll be able to process the 52 files tomorrow now...
Have a nice evening,
PY
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.