BookmarkSubscribeRSS Feed
Sourav_sas
Quartz | Level 8

I am using the following SAS code

proc printto log="/var/opt/data/data_project/sas94/bire/redwh/logs/PooledWorkspaceServer/one.log";
run;


data one;
Input A  B $;
Datalines;
1 A
2 b
;                                                                                                                                    
run;

Here I can save my report log to somewhere.

 

I want to know that can you suggest me some sort of code where I can scan some test from that log file. I need to do that.

6 REPLIES 6
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Log files are just text files.  You can read in the text file, and process it how you like with string functions:

data want;
  infile ".../one.log";
  length instr $2000;
  input instr $;
  ...
run;
FredrikE
Rhodochrosite | Level 12

Using @RW9 's skeleton i'd continue using regular expressions so scan the data:

https://support.sas.com/rnd/base/datastep/perl_regexp/regexp-tip-sheet.pdf

 

//Fredrik

Sourav_sas
Quartz | Level 8

Actually I want to scan the log from that path, and then if error will be there, respect to some specific error like "Statement is not valid or it is used out of proper order"(suppose) then it will shoot one mail to me or user.

 

Note: I want to specify the error test in the condition. Not for all error.

 

I have used another sort of code. Here can we do anything?

Options obs=max nosymbolgen nomlogic nomprint;
%INCLUDE "/home/name/Test.sas";
%Let Joblog = /home/name/;
%Let Jobdate = &sysdate9.;
%Let Jobname = RUN_LoadTB_Refresh;
%LOGCHECK(&joblog.&JOBNAME._&jobdate..log,name);
run;

 

Please help me.

 

Thanks

Regards

Sourav

LinusH
Tourmaline | Level 20

What kind of report do you want to build?

It seems you are on Intelligence architecture, so if you have a quite recent release, you should be able to do stuff with Environment Manager OOTB.

Data never sleeps
Sourav_sas
Quartz | Level 8

I am working in SAS EG, and I am running some prompt related to this report through DI studio. But if I want to run the code only from EG, above sort of code I am using, but not able to specify the error text. My aim is to specify the error text in the code, and to get mail respect that error only from the log...

 

If there any possibilities that we can mention the error text in the condition or in the loop, instead of any error code no, please let me know, I am chasing for this issue for long time, I need one permanent solution on this...

 

 

Regards

Sourav

Sourav_sas
Quartz | Level 8

Look in to the following code

Filename _log_ "/home/re00627/test.log";

Data Log1;
Infile _log_ truncover;
input a_line $200.;
/*If Substr(a_line,1,57) = 'Statement is not valid or it is used out of proper order.'*/
/**/
if index(a_line, 'Statement is not valid or it is used out of proper order.') > 0 

then Do;
/*index(a_line, 'WARNING') > 0*/
filename myfile email                                                                                                                   
to= "mail_id"                                                                                                               
subject= "Error in Report"                                                                                                              
type= "text/plain"
importance="HIGH";
data _null_;                                                                                                                          
   file myfile;                                                                                                                         
   put 'Dear User';                                                                        
   put;                                                                                                                                 
   put 'Due to your selection you are getting this mail.';                                                                                                                                                                                                                            
  put;                                                                                                                                 
   put 'Please go with some short selction.';                                                                                                                                                                                                                       
  run;
  End;

This code is not working, Here can you help me with some other option. If I am using, neither the index function is working nor SUSTR, if you have some easy solution please let e know.

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 6 replies
  • 3562 views
  • 1 like
  • 4 in conversation