Hello SAS members,
I merged some data sets and got some missing values in my new merged data set. Currently it looks like this:
ID Date Age Group Workout_mins
1 1 35 35 60
1 2 . . 45
1 3 . . 0
...
So basically age and group stay the same, how can I imput the values based on existing values to the . in the data set (i.e. "." => 35, etc.)
Thanks!
Not clear with this "." => 35,
do you want missings to be imputed with previous non missing value?
if yes
data have;
input ID Date Age Group Workout_mins ;
cards;
1 1 35 35 60
1 2 . . 45
1 3 . . 0
;
data want;
update have(obs=0) have;
by id;
output;
run;
Yes, since the person with ID 1 is 35 years old as seen in the row above, the . in the below row should be the same value (35). Could you explain what is
have(obs=0) havein your codes?
@mkt_apprentice some reading about update statement here http://support.sas.com/documentation/cdl/en/basess/58133/HTML/default/viewer.htm#a001329151.htm
will help you
data have;
input ID Date Age Group Workout_mins ;
cards;
1 1 35 35 60
1 2 . . 45
1 3 . . 0
;
data want;
retain h_age 0;
set have;
if first.id then h_age = age;
if age <= h_age then age = h_age;
by id;
drop h_age;
run;
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.