LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (January 2010, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 6 Jan 2010 12:19:19 -0500
Reply-To:     Ya Huang <ya.huang@AMYLIN.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Ya Huang <ya.huang@AMYLIN.COM>
Subject:      Re: Properly Flagging items based on multiple conditions
Comments: To: sdlentertd@GMAIL.COM

data xx; input STORE RNUM DAYS date :date.; or=_n_; 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 ;

proc sort; by store rnum date; run;

data xx; set xx; by store rnum; pred=lag(days); if first.rnum then pred=.; if pred >=90 and days < 90 then flag='Y'; run;

proc sort; by or; run;

proc print; run;

STORE RNUM DAYS date or pred flag

1212 456 20 18263 1 . 1212 468 90 18263 2 . 1212 456 90 18264 3 20 1212 468 30 18264 4 90 Y 2566 468 10 18265 5 . 1212 456 30 18266 6 90 Y

In your sample, you flagged first obs for 468, where days=90. But flagged last obs for 456 where days < 90. In my code, always flag the one < 90.

On Wed, 6 Jan 2010 08:41:35 -0800, Sdlentertd <sdlentertd@GMAIL.COM> wrote:

>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?


Back to: Top of message | Previous page | Main SAS-L page