- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
So it looks like you are check for ERROR: starting in first column (or in your case immediately following linefeed) which means we don't need to write the kind of crazy code I have seen to avoid having ERROR: appear in the code that is echoed to the long.
Things like:
%put %str(ERR)OR: Macro parameter invalid.;
put 'ERR' 'OR: Value out of range.';
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Not sure what that code is.
But, the example I showed was from one of the access methods that doesn't have the issue with user content showing up embedded prior to the actual SAS log line (I think it was IOM). The STDIO access method has to deal with that, and in it the check has to deal with that:
def _checkLogForError(self, log):
lines = re.split(r'[\n]\s*', log)
for line in lines:
if re.search(r'^ERROR[ \d-]*:', line[self._sb.logoffset:]):
return (True)
return (False)
Do you have some code where this isn't doing what you need?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@sastpw wrote:
Not sure what that code is.
But, the example I showed was from one of the access methods that doesn't have the issue with user content showing up embedded prior to the actual SAS log line (I think it was IOM). The STDIO access method has to deal with that, and in it the check has to deal with that:
def _checkLogForError(self, log):
lines = re.split(r'[\n]\s*', log)
for line in lines:
if re.search(r'^ERROR[ \d-]*:', line[self._sb.logoffset:]):
return (True)
return (False)
Do you have some code where this isn't doing what you need?
Not talking about scanning the actual code. Just the SAS log itself. SAS logs echo the code, unless the user mistakenly set the NOSOURCE option.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@sastpw wrote:
Not sure what that code is.
...
Do you have some code where this isn't doing what you need?
I don't really use SASPy but if you want to test if your logic makes the same mistakes as some of the other code scanners I was complaining about try running this program.
* Check if AGE is missing ;
data _null_;
set sashelp.class;
if missing(age) then put 'ERROR: Age is missing for ' name= ;
run;
You should get this as the LOG
1 * Check if AGE is missing ; 2 data _null_; 3 set sashelp.class; 4 if missing(age) then put 'ERROR: Age is missing for ' name= ; 5 run; NOTE: There were 19 observations read from the data set SASHELP.CLASS. NOTE: DATA statement used (Total process time): real time 0.10 seconds cpu time 0.06 seconds
And it should NOT be flagged as having an error.
Then try modifying the code so that it does print the error.
data _null_;
set sashelp.class;
if _n_=2 then call missing(age);
if missing(age) then put 'ERROR: Age is missing for ' name= ;
run;
Display Manger will show the error message in RED.
And your error check code should also find that error message.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the comments! Excellent explanation! Would SASpy also provide another flag like?
check_warning_log
Thus, if either of check_warning_log or check_error_log is true, user can consider that the SAS program is not run smoothly.
From my perspective, we use Automation tool to schedule the .sas programs which are written by others. It's not easy to change the existing .sas program files to add additional checks on each data step.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
No, I don't have check_warnings or check_notes. You can check for anything in the log you'd like; submit returns the log and something as simple as
if re.search(r'\nERROR[ \d-]*:', log):
can be used to look for others.
There's no magic thing I can check for, for any code ever submitted, that proves everything worked or didn't. SAS doesn't really have that concept. Saying it failed because there was a warning isn't really correct anyway. Just seeing an error doesn't mean it failed either; you can get an error in the log and things still succeeded. That logic is something you want to determine based upon what you're running and what you expect.
I get that trying to automate this for code you didn't write isn't straight forward. I suppose looking for errors or warnings and then telling someone to look at the code/log and see if there weas an issue or not is simple. But you can't simply prove it worked or not w/out knowing what's going on.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks! I know it's not perfect to check key words like ERROR or WARNING in SAS log. However, it provides a solution for us to notify operators that something should be paid attention to. I know for each .sas program running, operator should at least take a look at the details of SAS log file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Just curious to understand why you are persevering with the SASPy interface when if you run a SAS job directly via a scheduler (perhaps via SAS Management Console) you can trigger emails if there are warnings or errors in SAS logs out-of-the-box with no checking with extra coding at all. This is what we do and if there are emails we go and check the SAS logs. This typically happens with a very small number of SAS jobs so manual checking is quick and efficient.
- « Previous
-
- 1
- 2
- Next »