BookmarkSubscribeRSS Feed
mkt_apprentice
Obsidian | Level 7

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!

6 REPLIES 6
novinosrin
Tourmaline | Level 20

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;
mkt_apprentice
Obsidian | Level 7

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
Obsidian | Level 7
Thank you for the reference reading!
I got that "want" is the newly modified data set by revising master data set "have(obs=0)" by the information in the data set "have". Could you help explain what does "have (obs=0)" refer to? Obs is not a variable right, so what does obs=0 refer to?
VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

 

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;

 

 

mkt_apprentice
Obsidian | Level 7
Hi VDD, what does 0 in the second coding line indicate (retain h_age 0)?

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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
  • 6 replies
  • 918 views
  • 0 likes
  • 3 in conversation