BookmarkSubscribeRSS Feed
chetan3125
Obsidian | Level 7

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  */

 

 

image.png

1 REPLY 1
jimbarbour
Meteorite | Level 14

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.

jimbarbour_0-1603595995419.png

 

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.

jimbarbour_1-1603596135833.png

 

Jim

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

SAS Enterprise Guide vs. SAS Studio

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.

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
  • 1 reply
  • 948 views
  • 0 likes
  • 2 in conversation