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
SAS Super FREQ
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

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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.

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
  • 684 views
  • 0 likes
  • 2 in conversation