BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
bkq32
Quartz | Level 8
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?

1 ACCEPTED SOLUTION

Accepted Solutions
SASKiwi
PROC Star
proc compare base = bweight_old compare = bweight_new; 
 ods select CompareDifferences;
 id patient_id;
run;

View solution in original post

4 REPLIES 4
SASKiwi
PROC Star
proc compare base = bweight_old compare = bweight_new; 
 ods select CompareDifferences;
 id patient_id;
run;
bkq32
Quartz | Level 8

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.

ballardw
Super User

@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.

bkq32
Quartz | Level 8

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.

SAS Innovate 2025: Register Now

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!

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
  • 4 replies
  • 798 views
  • 0 likes
  • 3 in conversation