Help using Base SAS procedures

Assign Values for Missings

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 7
Accepted Solution

Assign Values for Missings

Hi there,

I have a data set as the picture shows below. For variable R, it has a lot of missing values. What I want to do is to assign the existing value to all the previous blanks. For example, assign 1.0219 to observation 1-10 of R, and assign 0.9598 to observations 12 to 20. Finally the variable R will have 0 missing values. Any ideas?

TIA!

A.jpgA


Accepted Solutions
Solution
‎05-15-2013 01:08 AM
Super User
Posts: 10,046

Re: Assign Values for Missings

Posted in reply to PeterPanPan

OK.

data have ;
input a b;
cards;
1 .
2 .
3 4
4 5
5 .
6 .
7 .
8 9
;
run;
data want;
do until(not missing(b));
 set have;
end;
c=b;
do until(not missing(b));
 set have; output;
end;
run;


Ksharp

View solution in original post


All Replies
Solution
‎05-15-2013 01:08 AM
Super User
Posts: 10,046

Re: Assign Values for Missings

Posted in reply to PeterPanPan

OK.

data have ;
input a b;
cards;
1 .
2 .
3 4
4 5
5 .
6 .
7 .
8 9
;
run;
data want;
do until(not missing(b));
 set have;
end;
c=b;
do until(not missing(b));
 set have; output;
end;
run;


Ksharp

Occasional Contributor
Posts: 7

Re: Assign Values for Missings

Thank you so much, Ksharp, you solved my problem!

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 174 views
  • 2 likes
  • 2 in conversation