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) have
in 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;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.