Help using Base SAS procedures

Merge or Set

Reply
N/A
Posts: 0

Merge or Set

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
SAS Super FREQ
Posts: 8,743

Re: Merge or Set

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
Ask a Question
Discussion stats
  • 1 reply
  • 114 views
  • 0 likes
  • 2 in conversation