Populate the missing values with baseline result where consider Visit=V1 as baseline.
USUBJID | PARAM | _NAME_ | V1 | V2 | V3 | V4 |
10 | SYSBP | AVAL | 100 | 120 | 130 | 110 |
20 | SYSBP | AVAL | 90 | 100 | 120 | . |
Here you are:
data have;
input USUBJID $ PARAM $ _NAME_ $ V1 V2 V3 V4;
cards;
10 SYSBP AVAL 100 120 130 110
20 SYSBP AVAL 90 100 120 .
;
run;
data want(drop=i);
set have;
array vs{*} V:;
do i=2 to dim(vs);
if vs(i)=. then vs(i)=v1;
end;
run;
/* end of program */
Koen
In a DATA step
if missing(v4) then v4=v1;
Here you are:
data have;
input USUBJID $ PARAM $ _NAME_ $ V1 V2 V3 V4;
cards;
10 SYSBP AVAL 100 120 130 110
20 SYSBP AVAL 90 100 120 .
;
run;
data want(drop=i);
set have;
array vs{*} V:;
do i=2 to dim(vs);
if vs(i)=. then vs(i)=v1;
end;
run;
/* end of program */
Koen
Hello,
It's (data step) array processing.
You put all the variables starting with the letter 'V' in a numerical array (the colon : is a wildcard to avoid putting V1 V2 V3 V4).
You then use a do-loop to screen V2, V3 and V4 for a missing value. If missing, put the value of V1.
Kind regards,
Koen
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.