Reputation: 661
I have a question. I want to ask my question as an example. I have the following datasets:
AAA Value
1 25
2 .
3 .
4 22
5 .
As you can see, there are some missing observations in column VALUE. I want to equalize this missing value to previous observations. So, the result should be:
AAA Value
1 25
2 25 ( because the previous number is 25)
3 25 ( because the previous number is 25)
4 22
5 22 ( because the previous number is 22)
Many thanks in advance.
Upvotes: 1
Views: 35
Reputation: 15698
you need to use the retain statement.
data new;
set old;
retain newvalue;
drop newvalue;
if value ne . then newvalue = value;
if value = . then value = newvalue;
run;
Just beware that if the first 'value' is a '.' it won't fill in
Upvotes: 2