Help using Base SAS procedures

Merge or Set

Not applicable
Posts: 0

Merge or Set


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 ,

Posts: 9,368

Re: Merge or Set

Posted in reply to deleted_user
Have you read the documentation on combining SAS datasets???


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).

Ask a Question
Discussion stats
  • 1 reply
  • 2 in conversation