Programmatically check log for error messages?

Reply
Contributor
Posts: 29

Programmatically check log for error messages?

As the subject line says, is there a way to programmatically check the log for error/warning messages?

I'm thinking in terms of a yes/no macro variable, or maybe an option to stop submitting code once there is an error message.

Thanks!
Trusted Advisor
Posts: 2,114

Re: Programmatically check log for error messages?

If you save the log to a file, you can search it with grep or using the SAS perl regular expressions. I'm not sure that is what you were searching for, but it works reasonably well in a batch environment.

Doc Muhlbaier
Duke
N/A
Posts: 0

Re: Programmatically check log for error messages?

In my humble opinion, the best approach by far is to save the log as a file and then parse it for any of the SAS statements that indicate we have wrong data, bad code, system issues or misunderstandings. These can be as simple or as comprehensive as you need.

You might also look up the system macro symbols in the documentation that start with %Sys. These can give you some insight into the success or failure of individual steps.

Kind regards

David
Contributor
Posts: 29

Re: Programmatically check log for error messages?

Thanks to both!
Contributor
Posts: 45

Re: Programmatically check log for error messages?

For those using Unix, a shell program like the following could catch common errors:

#!/bin/ksh
if [ $# != 1 ]
then
echo "Usage: mylogchecker.sh "
exit -1
fi

grep -n ERROR ./$1
grep -n WARNING ./$1
grep -in UNINITIALIZED ./$1
grep -in CONVERTED ./$1
grep -in REPEATS ./$1
grep -in 'BY ZERO' ./$1
grep -in UNKNOWN ./$1
grep -in 49-169 ./$1
exit
Ask a Question
Discussion stats
  • 4 replies
  • 634 views
  • 0 likes
  • 4 in conversation