hi, i have a dataset as follows -
date present
01AUG2009
02AUG2009
03AUG2009
04AUG2009 Y
05AUG2009
06AUG2009
07AUG2009
08AUG2009
09AUG2009 Y
10AUG2009
11AUG2009 Y
12AUG2009
is there a way i can fill in the blanks between the first and last
dates where a Y is recorded?
thanks,
nick
|
|
0
|
|
|
|
Reply
|
nickcorbin0000 (9)
|
11/21/2009 12:24:19 PM |
|
data want;
/*retain the variable order*/
if _n_=0 then set test;
/*stop when it hits a Y*/
do _n_=1 by 1 until(present='Y' or last);
set test end=last;
y+(present='Y');
lastP=present;
end;
/*fill the gap and output*/
do _n_=1 to _n_;
set test;
if y>1 and missing(present) and lastP='Y'
then present='Y';
output;
end;
drop lastp y;
run;
On Sat, Nov 21, 2009 at 6:24 AM, nick <nickcorbin0000@googlemail.com> wrote:
> hi, i have a dataset as follows -
>
> date present
>
> 01AUG2009
> 02AUG2009
> 03AUG2009
> 04AUG2009 Y
> 05AUG2009
> 06AUG2009
> 07AUG2009
> 08AUG2009
> 09AUG2009 Y
> 10AUG2009
> 11AUG2009 Y
> 12AUG2009
>
>
> is there a way i can fill in the blanks between the first and last
> dates where a Y is recorded?
>
> thanks,
>
> nick
>
|
|
0
|
|
|
|
Reply
|
zhangyu05 (659)
|
11/23/2009 4:28:54 PM
|
|