data bweight_old ( keep = patient_id weight--momage );
format patient_id;
set sashelp.bweight;
if _N_ <= 6;
if _N_ in ( 1, 2 ) then patient_id = "A1";
if _N_ in ( 3, 4 ) then patient_id = "A2";
if _N_ in ( 5, 6 ) then patient_id = "A3";
run;
data bweight_new;
set bweight_old;
if _N_ = 2 then weight = .;
if _N_ = 3 then momage = .;
run;
proc compare base = bweight_old compare = bweight_new;
ods select CompareDifferences;
run;
In the proc compare output, is there a way for me to see which PATIENT_ID an observation corresponds to?
proc compare base = bweight_old compare = bweight_new;
ods select CompareDifferences;
id patient_id;
run;
proc compare base = bweight_old compare = bweight_new;
ods select CompareDifferences;
id patient_id;
run;
Thank you! I was worried I was doing something wrong because of the warnings in the log about the duplicate IDs, but I guess I'll just ignore them since that's the way the data are structured.
@bkq32 wrote:
Thank you! I was worried I was doing something wrong because of the warnings in the log about the duplicate IDs, but I guess I'll just ignore them since that's the way the data are structured.
Unless you are trying to detect an order difference between to data sets you may want to consider sorting both data sets by several variables and have all of those on the ID statement. Multiple variables on the ID require presorting.
Thanks, @ballardw. If I'm understanding this correctly, I think I should be okay since I only have one ID and I'm just taking data set A and running a macro that outputs data set B with the outliers set to null, so the order of the rows should still be exactly the same between A and B.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.