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.

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 406 views
  • 0 likes
  • 3 in conversation