Date: Thu, 4 Oct 2007 13:56:49 -0400
Reply-To: souga soga <souga1234@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: souga soga <souga1234@GMAIL.COM>
Subject: Re: Flagging observations
In-Reply-To: <200710032204.l93L2tMK018085@mailgw.cc.uga.edu>
Content-Type: text/plain; charset=ISO-8859-1
Thank you all for taking the time to provide these excellent responses.It is
much appreciated.
Sa
On 10/3/07, Ya Huang <ya.huang@amylin.com> wrote:
>
> data x;
> set test;
> by x notsorted;
> if first.x and x=. then grp+1;
> run;
>
> proc print;
> run;
>
> Obs x gr
>
> 1 . 1
> 2 . 1
> 3 . 1
> 4 10 1
> 5 10 1
> 6 . 2
> 7 . 2
> 8 . 2
> 9 20 2
> 10 20 2
> 11 . 3
> 12 . 3
> 13 . 3
> 14 30 3
> 15 40 3
> 16 . 4
> 17 . 4
> 18 . 4
> 19 50 4
> 20 60 4
>
> On Wed, 3 Oct 2007 17:45:10 -0400, souga soga <souga1234@GMAIL.COM> wrote:
>
> >Hi ,
> >
> >I have a data set:
> >DATA test;
> >
> >x=.;OUTPUT;
> >x=.;OUTPUT;
> >x=.;OUTPUT;
> >x=10;OUTPUT;
> >x=10;OUTPUT;
> >x=.;OUTPUT;
> >x=.;OUTPUT;
> >x=.;OUTPUT;
> >x=20;OUTPUT;
> >x=20;OUTPUT;
> >x=.;OUTPUT;
> >x=.;OUTPUT;
> >x=.;OUTPUT;
> >x=30;OUTPUT;
> >x=40;OUTPUT;
> >x=.;OUTPUT;
> >x=.;OUTPUT;
> >x=.;OUTPUT;
> >x=50;OUTPUT;
> >x=60;OUTPUT;
> >
> >RUN;
> >*
> >
> >I would like to flag observations sequentially that start with the
> >first missing value and end with the last non-missing value.
> >
> >Here is the expected output.
> >
> >x=.;Flag=1;
> >x=.;Flag=1;
> >x=.;Flag=1;
> >x=10;Flag=1;
> >x=10;Flag=1;
> >
> >x=.;Flag=2;
> >x=.;Flag=2;
> >x=.;Flag=2;
> >x=20;Flag=2;
> >x=20;Flag=2;
> >x=.;Flag=3;
> >x=.;Flag=3;
> >x=.;Flag=3;
> >x=30;Flag=3;
> >x=40;Flag=3;
> >x=.;Flag=4;
> >x=.;Flag=4;
> >x=.;Flag=4;
> >x=50;Flag=4;
> >x=60;Flag=4;
> >
> >Thanks,
> >
> >Sa
> >
> >*
>
|