|
> -----Original Message-----
> From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
> Sdlentertd
> Sent: Wednesday, January 06, 2010 8:42 AM
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: Re: Properly Flagging items based on multiple conditions
>
> On Jan 5, 2:11 pm, Sdlentertd <sdlente...@gmail.com> wrote:
> > I have this dataset and I am looking to flag items for the same store
> > with the same R-number but that went from =>90 to <90 on days
> >
> > Have:
> > STORE R-NUMBER DAYS date
> > 1212 456 20 01jan2010
> > 1212 468 90 01jan2010
> > 1212 456 90 02jan2010
> > 1212 468 30 02jan2010
> > 2566 468 10 03jan2010
> > 1212 456 30 04jan2010
> >
> > So first I need to look at the stores to make sure I am analyzing the
> > same store, then I am looking at R-Number and if it's the same then
> > look at DAYS and Date, if it went from 90 to less (based on Date) then
> > Flag it.
> >
> > Want:
> > STORE R-NUMBER DAYS date FLAG
> > 1212 456 20 01jan2010
> > 1212 468 90 01jan2010 Y
> > 1212 456 90 02jan2010
> > 1212 468 30 02jan2010
> > 2566 468 10 03jan2010
> > 1212 456 30 04jan2010 Y
> >
> > (the last one is Y because at first it was 20 then it went to 90 and
> > then went DOWN to 30)
> > Thanks for any help
>
> Anyone?
\
Something like this will get you started:
data have;
input STORE R_NUMBER DAYS date :date9.;
cards;
1212 456 20 01jan2010
1212 468 90 01jan2010
1212 456 90 02jan2010
1212 468 30 02jan2010
2566 468 10 03jan2010
1212 456 30 04jan2010
;
run;
proc sort data= have;
by store r_number date;
run;
data want;
set have ;
by store r_number;
if first.r_number then GE90 = 0;
retain ge90;
if ge90 and days LT 90 then do;
flag = 'Y';
ge90 =0;
end;
if days GE 90 then ge90 = 1;
drop ge90;
run;
Hope this is helpful,
Dan
Daniel J. Nordlund
Washington State Department of Social and Health Services
Planning, Performance, and Accountability
Research and Data Analysis Division
Olympia, WA 98504-5204
|