BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
milts
Pyrite | Level 9

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?

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

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

5 REPLIES 5
Ksharp
Super User

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

milts
Pyrite | Level 9

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!

Ksharp
Super User

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

Ksharp
Super User

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

milts
Pyrite | Level 9

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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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