Convert from 12 hr clock to 24 hr clock

Reply
Occasional Contributor
Posts: 9

Convert from 12 hr clock to 24 hr clock

Is there a sas command to convert this 12 hr time into a 24 hr time. For instance I have time 3:00 PM which I'm reading in using: informat Time $8. ; and it works. I want to convert this to 15:00, how do I do that?

Respected Advisor
Posts: 3,777

Re: Convert from 12 hr clock to 24 hr clock

If you are reading from INFILE you may need & format modified.

19         data _null_;
20            t = '3:00 PM';
21            t2 = input(t,time8.);
22            put t= t2=time.;
23            run;
t=3:00 PM t2=15:00:00
24        
25         data _null_;
26            input time & time. comment & $40.;
27            put time=time.;
28            list;
29            cards;
time=15:00:00
RULE:      ----+----
1----+----2----+----3----+----
30         3:00 PM  Two blank spaces
31         ;;;;
32            run;
Ask a Question
Discussion stats
  • 1 reply
  • 967 views
  • 0 likes
  • 2 in conversation