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 (February 2007, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 8 Feb 2007 14:42:10 -0500
Reply-To:     hurley.gj@PG.COM
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "George J. Hurley" <hurley.gj@PG.COM>
Subject:      Re: Sum days
Comments: To: Syb it <sas_datalover@YAHOO.COM>
Content-Type: text/plain; charset="iso-8859-1"

Try something this:

data days_late; input id date_pick_check:date7. inc_days @@; format date_pick_check date7.; cards; 1 01-Jan-00 31 1 03-Feb-00 28 1 04-Mar-00 31 1 27-Mar-00 30 1 01-May-00 31 2 01-Mar-01 31 3 01-Jun-03 30 3 10-Jul-03 31 3 01-Aug-03 30 3 01-Sep-03 31 4 01-Apr-99 30 4 05-May-99 31 4 01-Jun-99 30 ; run; proc print; run;

proc sort data=days_lateb; by id date_pick_check; run;

data days_lateb; set days_late; by id; k=date_pick_check+0; y=lag(date_pick_check); z=lag(inc_days); if not first.id then do; diff=date_pick_check-y; end; late=diff-z; run;

proc sql; select id, sum(late) as totlate from days_lateb where late>0 group by id; quit;

George J. Hurley The Procter and Gamble Company Miami Valley Innovation Center, Box 30 11810 East Miami River Road Cincinnati, OH 45252 P: (513) 627-0692 F: (513) 945-3441

Syb it <sas_datalover@YAHOO.COM> Sent by: "SAS(r) Discussion" <SAS-L@listserv.uga.edu> 02/08/2007 02:22 PM Please respond to Syb it

To: SAS-L@listserv.uga.edu cc: Subject: Re: [SAS-L] Sum days

Dear All, date_ pick_ Obs id check inc_days

1 1 01JAN00 31 2 1 03FEB00 28 3 1 04MAR00 31 4 1 27MAR00 30 5 1 01MAY00 31 6 2 01MAR01 31 7 3 01JUN03 30 8 3 10JUL03 31 9 3 01AUG03 30 10 3 01SEP03 31 11 4 01APR99 30 12 4 05MAY99 31 13 4 01JUN99 30 Questions:

I am trying to figure out on average how late a person is to pick up their check. Consider person # 1 for example: (a) five checks were picked at given dates (b) Check is supposed to last a given month ($1/day) They picked up their 1st check on 01jan00, then 2nd on Feb 3rd. This person was late to pick up their second check by 2 days because each dollar lasts a day (that's the assumption). Now I need to sum for each person how late they would have been considering all check they would have

picked up (all records). NB: Checks can be collected earlier before the previous one is depleted (for example on 27 March for Id=1) was an early pick up.

Please help with some code ;)

data days_late; input id date_pick_check:date7. inc_days @@; format date_pick_check date7.; cards; 1 01-Jan-00 31 1 03-Feb-00 28 1 04-Mar-00 31 1 27-Mar-00 30 1 01-May-00 31 2 01-Mar-01 31 3 01-Jun-03 30 3 10-Jul-03 31 3 01-Aug-03 30 3 01-Sep-03 31 4 01-Apr-99 30 4 05-May-99 31 4 01-Jun-99 30 ; run; proc print; run;

--------------------------------- The fish are biting. Get more visitors on your site using Yahoo! Search Marketing.


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