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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.