Discussion:
A time5. format but hold more than 24 hours ?
(too old to reply)
Ya Huang
2007-10-25 16:32:32 UTC
Permalink
Hi there,

I want to show an elapse time as hh:mm format, but the hour part
may go over 24. For example, a='127:56:34't, I want it shown as
127:56. If I use time5., I'll get 127.

I tried to play around the picture format, but failed:

122 proc format;
123 picture mytime
124 low-high = '%0I:%0M' (datatype=time);
125 run;


126
127 data _null_;
128 a='7:56:34't;
129 put a time5. a mytime.;
130 a='127:56:34't;
131 put a time5. a mytime.;
132 run;

7:56 07:56
127 07:56

I change to '%00I:%0M', but not work either. I can't use time7., because I
don't want to see the second portion.

Any idea ?

Thanks

Ya
theorbo
2007-10-25 21:49:12 UTC
Permalink
Post by Ya Huang
Hi there,
I want to show an elapse time as hh:mm format, but the hour part
may go over 24. For example, a='127:56:34't, I want it shown as
127:56. If I use time5., I'll get 127.
I had a similar - but slightly different - issue back in September.

see the threads "days with gt 24 hours - merging by time" from September 10
and "PICTURE-based informats" from September 12.
Peter
2007-10-26 10:45:02 UTC
Permalink
Post by theorbo
Post by Ya Huang
Hi there,
I want to show an elapse time as hh:mm format, but the hour part
may go over 24. For example, a='127:56:34't, I want it shown as
127:56. If I use time5., I'll get 127.
I had a similar - but slightly different - issue back in September.
see the threads "days with gt 24 hours - merging by time" from September 10
and "PICTURE-based informats" from September 12.
SAS formats for time are about presenting time-of-day - see the
description for date/time directives in the proc format picture
statement
Post by theorbo
DOC>%H Hour (24-hour clock) as a decimal number (0-23), with no leading zero
DOC>%I Hour (12-hour clock) as a decimal number (1-12), with no leading zero
However, since a duration could be presented something like
days:hours:minutes:seconds
and we might present the day-in-month with picture directive %d
Post by theorbo
DOC>%d Day of the month as a decimal number (1-31), with no leading zero
This almost works
proc format;
picture mydtdurn /* my datetime duration definition */
0 - "31jan1960:23:59:59.99"dt
= '%0d:%0H:%0M:%0S' (datatype=datetime);
run;
%let from = 24oct07:12:00:15 ;
%let todt = 26oct07:11:16:00 ;
%put %sysfunc( range( "&from"dt, "&todt"dt), mydtdurn);
%put %sysfunc( range( "&from"dt, "&todt"dt), datetime);
The log showed
423 %put %sysfunc( range( "&from"dt, "&todt"dt), mydtdurn);
02:23:15:45
424 %put %sysfunc( range( "&from"dt, "&todt"dt), datetime);
02JAN60:23:15:45

Notice that the number of "days" = 2 when we want just 1
Unfortunately, SAS internal date and datetime assumption presents the
day as 1 for date=0
(1Jan1960)

I used the format hunter logic to search for some undocumented SAS
format for a duration value like we need here, but none turned up :-(

If you can see a valid context for this Duration-Type formatting, send
a suggestion to ***@sas.com

Good Luck

Peter.C
t***@gmail.com
2007-10-29 19:27:38 UTC
Permalink
If you are doing this in a datastep then you could use the PUT and
SUBSTR functions to get the value formated as you want into a
character variable.

data _null_;
time='12:30't;
time2= 8*'12:00't + time;
timec = substr(put(time2,time10.),1,7);
put time2 time2 time5. +1 time2 time8. +1 time2 time10. +1 timec;
run;

390600 108 108:30 108:30:00 108:30
toby dunn
2007-10-25 16:41:59 UTC
Permalink
Ya ,

Time6.2


Toby Dunn

Compromise is like telling a lie, it gets easier and easier. Each compromise you make, that becomes your standard.

Perfection doesnt exist, once you reach it, its not perfect anymore. It means something else.
Date: Thu, 25 Oct 2007 12:32:32 -0400
Subject: A time5. format but hold more than 24 hours ?
Hi there,
I want to show an elapse time as hh:mm format, but the hour part
may go over 24. For example, a='127:56:34't, I want it shown as
127:56. If I use time5., I'll get 127.
122 proc format;
123 picture mytime
124 low-high = '%0I:%0M' (datatype=time);
125 run;
126
127 data _null_;
128 a='7:56:34't;
129 put a time5. a mytime.;
130 a='127:56:34't;
131 put a time5. a mytime.;
132 run;
7:56 07:56
127 07:56
I change to '%00I:%0M', but not work either. I can't use time7., because I
don't want to see the second portion.
Any idea ?
Thanks
Ya
_________________________________________________________________
Windows Live Hotmail and Microsoft Office Outlook – together at last. Get it now.
http://office.microsoft.com/en-us/outlook/HA102225181033.aspx?pid=CL100626971033
Ya Huang
2007-10-25 16:52:17 UTC
Permalink
Actually, Toby was right, I can use time8.2

54 data _null_;
55 a='2327:56:34't;
56 put a time8.2;
57 run;

2327:56

So, the ':' here is like the decimal point in a number?
Thanks Toby,
34 data _null_;
35 a='2327:56:34't;
36 put a time6.2;
37 run;
2327
-----Original Message-----
Sent: Thursday, October 25, 2007 9:42 AM
Subject: RE: A time5. format but hold more than 24 hours ?
Ya ,
Time6.2
Toby Dunn
Compromise is like telling a lie, it gets easier and easier. Each
compromise you make, that becomes your standard.
Perfection doesnt exist, once you reach it, its not perfect anymore. It
means something else.
Date: Thu, 25 Oct 2007 12:32:32 -0400
Subject: A time5. format but hold more than 24 hours ?
Hi there,
I want to show an elapse time as hh:mm format, but the hour part may
go over 24. For example, a='127:56:34't, I want it shown as 127:56. If
I use time5., I'll get 127.
122 proc format;
123 picture mytime
124 low-high = '%0I:%0M' (datatype=time);
125 run;
126
127 data _null_;
128 a='7:56:34't;
129 put a time5. a mytime.;
130 a='127:56:34't;
131 put a time5. a mytime.;
132 run;
7:56 07:56
127 07:56
I change to '%00I:%0M', but not work either. I can't use time7.,
because I don't want to see the second portion.
Any idea ?
Thanks
Ya
_________________________________________________________________
Windows Live Hotmail and Microsoft Office Outlook - together at last. Get
it now.
http://office.microsoft.com/en-us/outlook/HA102225181033.aspx?
pid=CL100626971033
Huang, Ya
2007-10-25 17:00:47 UTC
Permalink
After some testing, I think hhmm would be safer than timew.d format in
this
case:

78 data _null_;
79 a='2327:56:34't;
80 put a hhmm10. / a time10.2;
81 run;

2327:57
2327:56:34

As you can see, when I increase timew.d format to time10.2, it starts to
show the
second portion, but hhmm10. still show only hour and minute portion,
which is
what I need.

Ya
-----Original Message-----
From: data _null_, [mailto:***@gmail.com]
Sent: Thursday, October 25, 2007 9:41 AM
To: Huang, Ya
Cc: SAS-***@listserv.uga.edu
Subject: Re: A time5. format but hold more than 24 hours ?

11 data _null_;
12 a='127:56:34't;
13 put a=hhmm7.;
14 run;

a=127:57
Post by Ya Huang
Hi there,
I want to show an elapse time as hh:mm format, but the hour part may
go over 24. For example, a='127:56:34't, I want it shown as 127:56. If
I use time5., I'll get 127.
122 proc format;
123 picture mytime
124 low-high = '%0I:%0M' (datatype=time);
125 run;
126
127 data _null_;
128 a='7:56:34't;
129 put a time5. a mytime.;
130 a='127:56:34't;
131 put a time5. a mytime.;
132 run;
7:56 07:56
127 07:56
I change to '%00I:%0M', but not work either. I can't use time7.,
because I don't want to see the second portion.
Any idea ?
Thanks
Ya
Loading...