Date: Tue, 17 Apr 2007 17:56:11 -0400
Reply-To: "Aspinall, Clifford G" <clifford.g.aspinall@PFIZER.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Aspinall, Clifford G" <clifford.g.aspinall@PFIZER.COM>
Subject: Re: elapsed hours to days and hours
In-Reply-To: A<200704172056.l3HHoGWH029297@mailgw.cc.uga.edu>
Content-Type: text/plain; charset="us-ascii"
I would just change the day assignment to day=ceil((hr+.5)/24). Of
course this only works with the times you gave. If you have 23.50 then
it wouldn't work. It really depends on what you want for your desired
results. Are you wanting a negative time when more than half a day has
elapsed?
data hr;
input hr;
day=ceil((hr+.5)/24);
tm=(hr-(day-1)*24);
cards;
23.75
24.25
26
95.75
96.25
98
167.75
168.25
170
;
proc print;
run;
Obs hr day tm
1 23.75 2 -0.25
2 24.25 2 0.25
3 26.00 2 2.00
4 95.75 5 -0.25
5 96.25 5 0.25
6 98.00 5 2.00
7 167.75 8 -0.25
8 168.25 8 0.25
9 170.00 8 2.00
Cliff
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Ya
Huang
Sent: Tuesday, April 17, 2007 4:57 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: elapsed hours to days and hours
Hi there,
Output of the following is followed the code:
data hr;
input hr;
day=ceil(hr/24);
tm=hr-(day-1)*24;
cards;
23.75
24.25
26
95.75
96.25
98
167.75
168.25
170
;
proc print;
run;
hr day tm
23.75 1 23.75
24.25 2 0.25
26.00 2 2.00
95.75 4 23.75
96.25 5 0.25
98.00 5 2.00
167.75 7 23.75
168.25 8 0.25
170.00 8 2.00
What I want is :
hr day tm
23.75 2 -0.25
24.25 2 0.25
26.00 2 2.00
95.75 5 -0.25
96.25 5 0.25
98.00 5 2.00
167.75 5 -0.25
168.25 8 0.25
170.00 8 2.00
Is there a simple logic I can use, without having to
code many "if then" or "select when" ?
Thanks
Ya
----------------------------------------------------------------------
LEGAL NOTICE
Unless expressly stated otherwise, this message is confidential and may be privileged. It is intended for the addressee(s) only. Access to this E-mail by anyone else is unauthorized. If you are not an addressee, any disclosure or copying of the contents of this E-mail or any action taken (or not taken) in reliance on it is unauthorized and may be unlawful. If you are not an addressee, please inform the sender immediately.