DATA Step, Macro, Functions and more

How to read/format time values

Reply
New User
Posts: 1

How to read/format time values

[ Edited ]

I am working with an assignment.

Here is the code- 

data XXX;
81 infile datalines;
82 length time 8;
83 informat time time5.;
84 format time time5.;
85 input @1time @8With $5.;

 

I want the time as in this format- 

11:00

9:00

3:00 

I tried many different set of codes but I could not find a code which would provide the desired output.

Please help me if you could.

Thanks 

Anu

Super User
Posts: 19,876

Re: Help me find a better code

Posted in reply to anucharbe

What does the data look like originally?

Community Manager
Posts: 2,956

Re: Help me find a better code

Posted in reply to anucharbe

Hi Anu,

 

Do you have an external file that you're reading this data from?  Can you post a portion of that?

 

And are you looking to represent clock times (9:00 AM or 13:00 24-hr time)?  Or something like a time span (6:45 for 6 hrs, 45min)?

 

What's the "WITH" variable?


Chris

Super User
Posts: 10,046

Re: How to read/format time values

Posted in reply to anucharbe
data x;
x='09:00:00't;
format x hhmm5.;
run;
Ask a Question
Discussion stats
  • 3 replies
  • 222 views
  • 0 likes
  • 4 in conversation