Hi ,
I am using EG 7.1 and adding some custom code before and after submitted code to get some additional SAS notes
as warnings as shown below.
I want to hide all the code in the before and after block and just see a clean log when I submit actual code.
I tried to use nosource / nonotes system option but it is not working for some part of the code.
Is it possible to hide the before and after block code from log ?
Thanks.
/* insert BEFORE submitted code */
/* options nonotes nosource */
%let var1 = something ;
%let var2 = something ;
%let var3 = something ;
%macro errors1 ;
filename LogFile temp;
Proc printto log=LogFile new;
run;
%mend errors1;
%errors1 ;
/*end of insert before code*/
/******************************************************************************************/
/* Insert AFTER submitted code */
/*following code gets additional warnings in my EG log */
%macro errors2 ;
/* Insert custom code after submitted code here */
proc printto;
run;
%let __NOTE_CHECK__ =is uninitialized|Invalid|MERGE statement has more than one
data set|values have been converted/*|Input data set is empty*/|W.D format|Missing
values were generated|Unknown|will be overwritten by|Division by zero|Format was to
small|truncated|ALERT_C|ALERT_P|ALERT_R ;
data _null_ ;
infile LogFile truncover lrecl=30000;
input;
length content$30000;
content=_infile_;
/* Change ERROR \d-\d to ERROR: */
content = prxchange('s/ERROR( +\d+-\d+: +)/ERROR:\1/o', 1,content);
/* Change PRG-ERROR: to ERROR: for %m_adam_create special log*/
content = prxchange('s/^PRG-ERROR:/ERROR:\1/o', 1,content);
/* For alerts */
if prxmatch ("m/ALERT_R|ALERT_C|ALERT_P/oi",content)>0 then do ;
if index (content, "small|truncated|ALERT_C|ALERT_P|ALERT_R")>0 then ex=1 ; ;
if index (content, "if prxmatch")>0 then ex=1 ;
/*if index (content ,'if prxmatch') =0 then */
if ex ne 1 then content = 'WARNING:' || content ;
end;
/* for overwritten info */
if index (content,'INFO:') and index (content,'overwritten') then do ;
content = prxchange('s/^INFO:/ERROR:\1/o', 1,content);
end;
/* Replace special notes with warning*/
pattern = prxparse("/(?<=^NOTE:).+\b(&__NOTE_CHECK__)\b/o");
if prxmatch(pattern, content) then do;
content = prxchange('s/^NOTE: /WARNING: /o',1,strip(content));
end;
/* put log out*/
len=length(content);
putlog content $varying200. len;
run;
/* %symdel __NOTE_CHECK__; */
%mend errors2 ;
%errors2;
/* end of submit after code */
Well, oddly, it seems to be working for me.
Make sure that the very first line in your special BEFORE code is OPTIONS NONOTES NOSOURCE and that the very last line is OPTIONS NOTES SOURCE. Also, make sure you have a semi-colon after your Options statements. I couldn't see a semi-colon in the code you posted.
When I do these things, the only thing I see from the special BEFORE code is a Options Nonotes Nosource which I think you just have to live with. Here I'm using a simple Data step as my test code that runs after the special BEFORE code.
Jim
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.