I have two tables: "bweight_old" and "bweight_new". The only difference between the two is that in "bweight_new", I set outliers to null. How can I create table "bweight_want" that lists only the variables that changed, specifying the PATIENT_ID, the variable name of the outlier, and the value of the outlier in "bweight_old".
data bweight_old;
format patient_id;
set sashelp.bweight;
patient_id+1;
run;
data bweight_new;
set bweight_old;
if patient_id=25 then weight=. and momwtgain=.;
if patient_id=2020 then cigsperday=.;
if patient_id=2029 then momwtgain=.;
run;
data bweight_want;
format patient_id variable originalvalue;
length variable $20.;
input patient_id variable $ originalvalue ;
cards;
25 weight 4050
25 momwtgain -20
2020 cigsperday 20
2090 momwtgain -2
;
run;
This is what I started with, but I'm not sure where to go from here.
proc compare base = bweight_old compare = bweight_new out = bweight_want
outnoequal outbase outcomp noprint;
id patient_id;
run;
... View more