I have many files in the work library with the names as data01, data02, data03, ... data50. All these dataset have the same contents, with one variable as the key.
My question is how can I merge all these files easily? I tried to do it using : as below, but failed.
data work.data;
merge data: ;
run;
Many thanks.
Did you get an error message or just not get the expected results?
Are you running at least version 9.2?
Works for me.
data data01 data02;
set sashelp.class;
run;
data data;
merge data:;
by name;
run;
If they all have the same contents it sounds more like you want to set them together rather than merge them.
Sorry the datasets are different. So it is definitely a merge. The datasets have one same variable.
Did you get an error message or just not get the expected results?
Are you running at least version 9.2?
Works for me.
data data01 data02;
set sashelp.class;
run;
data data;
merge data:;
by name;
run;
Thanks, Tom. I just got it right. Basially, the values in the key variable are: pctile1, pctile2, ... pctile10, pctile11, So the values are not sorted, thought it looks like they are Sorry and thanks!
Hi,
Even it worked for me! Here's what I have:
data data01;
input key col1;
cards;
1 101
2 102
3 103
4 104
5 105
;
run;
data data02;
input key col1;
cards;
1 101 <-- This col is same as previous dataset
6 102
7 103
8 104
9 105
;
run;
data want;
merge data01 data02;
by key;
run;
Result Set:
Key Col1
1 101
2 102
3 103
4 104
5 105
6 102
7 103
8 104
9 105
Do you have the same column name in all the tables? If possible provide example of what you have.
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 the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.