Is there a format to print time values with leading zeros?

  • Follow


Hi,

SAS 9.1.3 SP 4, Windows XP

Is there a format to print time values (HH:MM, no seconds needed) in
24 hour format, i.e. with a leading zero?

A check of the doc indicates "no", but just wanted to confirm.  I just
want standard 24 hour time output, like 04:53 and 18:12.  24 hour time
output always uses a leading zero for hour < 10.  I'm surprised SAS
doesn't have a format to do this.

This is the best I could come up with - better approaches most
welcome.

data _null_;
   time="09:59:59"t;  * "play" with this value, both < and > 10:00 ;
   timec=ifc(hour(time) <
10,cats("0",put(time,time5.)),put(time,time5.));
   put time =time5. timec=;
run;

Thanks,
Scott
0
Reply Scott 3/30/2010 9:03:33 AM

Hi Scott

Hope you're well.

Seems you forgot about picture formats.

Cheers
Patrick

proc format;
  picture _zhhmm
    other='%0H:%0M'
  (datatype=time);
run;

data _null_;
  time='5:12't;
  put time= _zhhmm.;
run;
0
Reply Patrick 3/30/2010 10:06:05 AM


1 Replies
551 Views

(page loaded in 0.484 seconds)

Similiar Articles:













7/24/2012 1:18:54 AM


Reply: