DATA Step, Macro, Functions and more

Correct time format

Accepted Solution Solved
Reply
Super Contributor
Posts: 326
Accepted Solution

Correct time format

Hi,

I'm trying to experiment of extracting values from a SAS log. Given values like the ff:

3:15:35.88

0.05 (seconds)

When converted, I'm getting a wrong value for the 2nd one. Converted values are the ff:

11735.88

300

I used TIME. informat to read them from the log. I need help to properly convert values which are less than a second. Any thoughts?


Accepted Solutions
Solution
‎05-17-2012 05:33 AM
Super User
Posts: 10,046

Re: Correct time format

Hi. I check the documentation. time. will take '.' as a delimiter, If you don't want it . using stimer.

data test;

     infile 'c:\TEST.log' expandtabs;

   input

          @'real time' real_time : stimer8.

          @'cpu time' cpu_time : stimer8.

     ;

format real_time cpu_time time8.;

run;

Ksharp

View solution in original post


All Replies
Super User
Posts: 10,046

Re: Correct time format

Can you post some LOG information and CODE you used and OUTPUT you need ?

Super Contributor
Posts: 326

Re: Correct time format

Hi,

Below is the code i tried. Also attaching portion of the log.

data test;

     infile '<path>/TEST.log';

     input

          @'real time' real_time : time8.

          @'cpu time' cpu_time : time8.

     ;

run;

Kindly correct if I there is something wrong in my sample code. Thanks!

Attachment
Super User
Posts: 10,046

Re: Correct time format

Hi.

It seems that SAS doesn't recognize 0.05 seconds.

Maybe you can try to use another informat  anydttme. to overcome it.

It will generate a missing value.If you want a zero, You can code something to transform it .

data test;
     infile 'c:\TEST.log' expandtabs;
   input
          @'real time' real_time : anydttme32.
          @'cpu time' cpu_time : anydttme32.
     ;
format real_time cpu_time time8.;
run;

Ksharp

Solution
‎05-17-2012 05:33 AM
Super User
Posts: 10,046

Re: Correct time format

Hi. I check the documentation. time. will take '.' as a delimiter, If you don't want it . using stimer.

data test;

     infile 'c:\TEST.log' expandtabs;

   input

          @'real time' real_time : stimer8.

          @'cpu time' cpu_time : stimer8.

     ;

format real_time cpu_time time8.;

run;

Ksharp

Super Contributor
Posts: 326

Re: Correct time format

Got the desired output. Thank you very much for the help.

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 311 views
  • 0 likes
  • 2 in conversation