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
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.