I have 15 datasets in a library. the data is already sorted. is there a way to merge them all together with out having to write each one out?
Thanks!
data class1 class2 class3;
set sashelp.class;
run;
/* if your datasets begin with same letters */
data want;
merge c:;
by name;
run;
/* begin with different letters */
proc sql noprint;
select memname into : names
from dictionary.tables
where libname='WORK'; /* note: libname must be in upcase */
data want;
merge &names;
by name;
run;
data class1 class2 class3;
set sashelp.class;
run;
/* if your datasets begin with same letters */
data want;
merge c:;
by name;
run;
/* begin with different letters */
proc sql noprint;
select memname into : names
from dictionary.tables
where libname='WORK'; /* note: libname must be in upcase */
data want;
merge &names;
by name;
run;
Thanks Lin Lin!
this is just what i was looking for.
the SQL method seems to merge class1 only.
sorry. using the updated one:
proc sql noprint;
select memname into : names separated by ' '
from dictionary.tables
where libname='WORK'; /* note: libname must be in upcase */
data want;
merge &names;
by name;
run;
Linlin
hi ... just modify the code (without "SEPARATED BY" you only get one memname) ...
proc sql noprint;
select memname into : names separated by ' '
from dictionary.tables
where libname='WORK'; /* note: libname must be in upcase */
quit;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.