Precautions while merging datasets in SAS


What Precautions would you take while merging two datasets in SAS ?

Precautions while merging datasets is one of the hot favourite questions of SAS interviewers.

Either you can give cliche answer for sake of answering, or you can answer to impress ... choice is all yours !




Cliche Answer :

Suppose, we are merging two datasets having "A" and "B" as common variables and we need to use both of these as merging variables.

1. Both the datasets should be sorted on "A" and "B"

2. The name of the variables "A" and "B" should be exactly same in both the datasets

In my experience, most of the people use above stated answer only ... However, I personally don't consider it to be correct one. 

Confused ???

Well, these two points can be considered as prerequisites for merging, but definitely not as precautions.

Why ???

Because, even if you don't take care of these points, SAS won't allow you to merge the data and you would find error in SAS Log in BOLD RED.





Then what should be the correct answer  ... ?


Answer to Impress :

The only precaution one should take while merging datasets is the relationship of the merging variables ("A" an "B") across datasets. The relationship could either be One -to-One, One-to-Many, Many-to-One .... But definitely not Many-to-Many.

But if interviewer insists to tell other precautions, you can tell him/her the two points ( from cliche Answer) .... but do mention what I have elaborated in this blog.

Basically, precaution should be taken against the phenomenon that is not visible by naked eye ( i.e. in SAS log). If you don't take care of the relationship among data, your result might be erroneous and Log won't tell you that.



Enjoy reading our other articles and stay tuned with ...

Kindly do provide your feedback in the 'Comments' Section and share as much as possible.