BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
tiffergirl18
Calcite | Level 5

Has anyone worked with CDC WONDER Multiple Causes of Death files and successfully merged datasets for multiple years (1999-2020)? I cannot figure out how to merge them after sorting.

 

https://communities.sas.com/t5/SAS-Programming/DUSMCPUB-files/m-p/863315/highlight/false#M341036

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

If you have SAS data sets you likely want to APPEND them, not Merge. Merge would be a side-by-side combination in SAS and makes no sense.

 

Proc Append base=Year1999 data=Year2000;

run;

will add Year 2000 to the end of the Year1999 data set. Repeat as needed.

If you want/need to manipulate the data while combining then you could use a data step such as

 

data want;
   set Year1999 - Year2020;
/* other manipulation code goes here*/
run;

The append will execute faster, enough to be noticeable with largish files, because the data step approach reads each record so that it can be manipulated with all the overhead involved. Append moves blocks of data faster as it doesn't have any such concern.

View solution in original post

1 REPLY 1
ballardw
Super User

If you have SAS data sets you likely want to APPEND them, not Merge. Merge would be a side-by-side combination in SAS and makes no sense.

 

Proc Append base=Year1999 data=Year2000;

run;

will add Year 2000 to the end of the Year1999 data set. Repeat as needed.

If you want/need to manipulate the data while combining then you could use a data step such as

 

data want;
   set Year1999 - Year2020;
/* other manipulation code goes here*/
run;

The append will execute faster, enough to be noticeable with largish files, because the data step approach reads each record so that it can be manipulated with all the overhead involved. Append moves blocks of data faster as it doesn't have any such concern.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 252 views
  • 1 like
  • 2 in conversation