Hi,
I have collected patients demographic characteristics for 19 months (from Dec. 2016-June 2018). Each month has its own dataset and the patients are not likely to be same people. Each dataset contains patient ID, sex, race, each month we approximately have 500-1000 patients.
How do I combine these 19 datasets into one? Writing the merge statement for 10+ times or sql? Any better idea? Thank you!
Only one set, and if you have clever names, you can use a wildcard:
data want;
set mydata:;
run;
eg if your datasets were work.mydata1 to work.mydata19.
You do not merge those datasets, but stack them, and add a variable for the period (SAS date preferred). The resulting vertical (long) dataset will be ideal for further processing.
I added a variable called "Month" so it will be 1-19 month when I stack them. My question is how do I easily stack 19 datasets?
Should I use "set" for 18 times?
Only one set, and if you have clever names, you can use a wildcard:
data want;
set mydata:;
run;
eg if your datasets were work.mydata1 to work.mydata19.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.
Ready to level-up your skills? Choose your own adventure.