BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Denali
Quartz | Level 8

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!

1 ACCEPTED SOLUTION

Accepted Solutions
3 REPLIES 3
Kurt_Bremser
Super User

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.

Denali
Quartz | Level 8

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?

Kurt_Bremser
Super User

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.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

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!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 930 views
  • 0 likes
  • 2 in conversation