Hello,
Using SAS 9.4
I have 2 data sets that have roughly the same data. Some of the variables overlap (i.e. name, dob, etc.) and some of the variables are exclusive to 1 data set or the other. I need to keep everything from both data sets.
Typically I would use something like:
data merged;
dataset1 (in=a) dataset2 (in=b);
run;
For these 2 data sets both have an ID that is for each patient, however some of the IDs duplicate between the 2 data sets. I need to keep both of the duplicate IDs without losing any of their information.
Is their a way to essentially stack the 2 data sets together without losing the information in the duplicate IDs? Thank you
Without samples of what you have and what you want, my dumb brain isn't able to guess your exact requirement
Are you after this by any chance?
data merged;
set dataset1 dataset2 ;
run;
EDIT : @ballardw Sorry sir, i didn't see your message. My apologies for the duplication of the same approaches.
Can you provide two small example data sets similar to your start and what you would want for the output?
Since you did not show either a SET, MERGE, UPDATE or MODIFY statement in your example code it isn't possible to tell exactly what you may have done previously.
A SET statement would stack the data sets with no loss
data merged; set dataset1 (in=a) dataset2 (in=b); run;
This assumes all of your variables in common between the two sets have the same type (numeric or character) and length. Different lengths will generate messages and possibly truncated data. Different types will not allow the combination to proceed as that would be an error.
Without samples of what you have and what you want, my dumb brain isn't able to guess your exact requirement
Are you after this by any chance?
data merged;
set dataset1 dataset2 ;
run;
EDIT : @ballardw Sorry sir, i didn't see your message. My apologies for the duplication of the same approaches.
@novinosrin wrote:
EDIT : @ballardw Sorry sir, i didn't see your message. My apologies for the duplication of the same approaches.
No worries. Sometimes different phrasing makes more sense to one person than another. Better to get at least one answer the OP can understand than none.
We also know that responses can be close in time because one response wasn't posted at the time you read a question but appears at about the same time when posting responses.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: