11-07-2017 02:40 PM
need final result:
sub model model_site
1 CT CT
1 US FG
1 xR YG
basically i have 2 different data set with subject and model. 'A' data set has 4 observations and 'B' data set has 3 observation. i need to merge this data set by Subject but i need to last row of model_site is missing.
11-07-2017 03:29 PM
Do you have multiple subjects?
Otherwise a MERGE without a BY statement is all you need, but I highly suspect your problem is more complicated.
Make sure your sample data accurately reflects your real data.
11-07-2017 03:42 PM - edited 11-07-2017 03:46 PM
Normally that is not what people want to do when they have two datasets with repeating by groups, but luckily for you it is very similar to how SAS data step merge handles combining observations when datasets contribute multiple observations per group. But normal SAS behavior is to retain the values from the last observation of the dataset with fewer observations.
You cannot prevent the retaining, but you can add code to write the observation and then clear all of the variables so nothing is retained.
data want ; merge A B ; by sub ; output; call missing(of _all_); run;