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
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.