BookmarkSubscribeRSS Feed
crawfjor
Calcite | Level 5

I am close to finishing a semester project working with loads of data sets together. Some needing to be combined vertically or horizontally, transposed, etc.

Anyway, I'm still at a point of not fully understanding the differences in a merge or set statement. I've combined data sets both ways but also have a tendency to cause issues I later have to deal with. Is it better to use a merge or set statement or what issues may I run into?

2 REPLIES 2
LinusH
Tourmaline | Level 20

Put simply:

Merge: combine data values into same record

Set: combine data into different records

 

 

 

 

Data never sleeps
Shmuel
Garnet | Level 18

Use MERGE when all data sets have the same key variables, same names and same type.

In case a variable X is numeric in one data set but char type in another you will have an issue,

either using merge or set.

 

To use MERGE all data sets should be first sorted by KEYs and finally you can merge them by KEYs.

Merging mean keeping the order of observations by KEYs.

 

By SET you concatenate the data sets (appending them) in the original order.

Finally you can sort it by KEYs to get same result as by using MERGE.

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 580 views
  • 0 likes
  • 3 in conversation