BookmarkSubscribeRSS Feed
deleted_user
Not applicable
HELLO ,

I need to merge two data sets . Both have the five similar variables.Should i use merge or set for this.Also , there is no common observation in the two datas so i shdnt use the sort ?

regards ,

mark
1 REPLY 1
Cynthia_sas
Diamond | Level 26
Hi:
Have you read the documentation on combining SAS datasets???
Concatenating:
http://support.sas.com/documentation/cdl/en/basess/58133/HTML/default/a001304348.htm

Merging:
http://support.sas.com/documentation/cdl/en/basess/58133/HTML/default/a001304305.htm

Basically, concatenating the datasets together might be something you would do if you had related datasets. For example, what if you have a dataset for every city's sales. and you wanted to "stack" or concatenate all the datasets together in order to have 1 dataset for the state sales? That might be a task you would do with PROC APPEND, DATA Step with SET statement or with PROC SQL.

But, imagine that you have a dataset of books and authors and ISBN numbers and that you have another dataset of ISBN numbers and publisher informationn. Those 2 files only have ISBN in common. You want to combine the two files so that you only have author and publisher information in a dataset for all the authors who are in the first file. This might be considered a situation where stacking the information was not appropriate and you used either a DATA Step MERGE or an SQL join to combine the datasets.

Reading the documentation will help you decide which method you need for your particular data. To concatenate or stack datasets, you do not have to sort the data prior to the concatenation; however, for the MERGE statement, both datasets must be in order by a matching variable prior to the merge or join. (In which case, a SORT might be needed).

cynthia

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 1 reply
  • 890 views
  • 0 likes
  • 2 in conversation