BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Haricasas12
Fluorite | Level 6

Populate the missing values with baseline result where consider Visit=V1 as baseline.

USUBJIDPARAM_NAME_V1V2V3V4
10SYSBPAVAL100120130110
20SYSBPAVAL90100120.
1 ACCEPTED SOLUTION

Accepted Solutions
sbxkoenk
SAS Super FREQ

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

View solution in original post

5 REPLIES 5
PaigeMiller
Diamond | Level 26

In a DATA step

 

if missing(v4) then v4=v1;
--
Paige Miller
sbxkoenk
SAS Super FREQ

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

Haricasas12
Fluorite | Level 6
Thanks a lot.. Its working.. Can briefly explain the code.. how is it working
sbxkoenk
SAS Super FREQ

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

 

Haricasas12
Fluorite | Level 6
Thank you so much for explanation..

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 5 replies
  • 767 views
  • 3 likes
  • 3 in conversation