SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
Question
Fluorite | Level 6
Hi All,
 
A quick question,
 
Has anyone ever used a SAS parser to step through a SAS log?. The problem I am having is I want to calculate the run time for each loop of a program written by a colleague.  Because I don't have access to the data yet I can't add statements to the macro to print to the log. The log I have prints the run time for each iteration. So what I want to do is find out the total run time for this dataset. There has to be a more efficient way than having to add up each iteration manually?
 
Your help would be much appreciated as it is a long log.
 
Thank you
7 REPLIES 7
Shmuel
Garnet | Level 18

You declared: "The log I have prints the run time for each iteration."

Did you "print" it into a file? what kind of file? Can you post a sample of that file ?

Peter_C
Rhodochrosite | Level 12
I have written prayers for SAS logs
They weren't short or simple. They (probably) wouldn't help with custom message for each "iteration" .. but we are all sas programmers...
If these iterations are in one data step, the step should give the step elapse time in log.
So please let us see the messages you want totalled.
For the next time?, recommend liberal use of
%put INFO: at %put %sysfunc( now(), datetime17.2) ;
Peter_C
Rhodochrosite | Level 12
when did parsers become prayers!

Thanks autocorrect
PhilC
Rhodochrosite | Level 12

Are you aware of PROC PRINTTO?  You didn't mention if you were able to send your log to a file yet.  Well if you already know, this should help the person using this article in the furture.

 

Example: SAS Help Center: Routing to External Files

ballardw
Super User

May want option Fullstimer with Stimer set when creating the log.

Tom
Super User Tom
Super User

I usually scan for lines that with MPRINT(... so I can see what macro is running.

If you are asking for the timing from data steps or proc steps then I normally also scan for DATA ... or PROC ... and remember.

Or scan for the NOTE: lines that say how many observations and variables were written.

You can use RETAIN to keep the dataset name or macro name and then search for and read the lines with the timing information. I seem to remember you need to use STIMER informat to read the times. Or perhaps count the numbers colons and prefix the string with enough extra '00:' so the seconds don't become hours.

 

In terms of counting the loops if there is not a distinct dataset name for each loop then look for some distinct line in the log you can use to detect when a new loop starts and increment a counter.

SASKiwi
PROC Star

I suggest you check out PROC SCAPROC 

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 1964 views
  • 0 likes
  • 7 in conversation