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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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