BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Shmuel
Garnet | Level 18

Please attach your code using the {i} icon. It will be easier to read and to locate errors.

Attaching a .txt file is not very friendly and less usefull.

Abraham
Obsidian | Level 7
%let run=&sysdate;
%let SYscc=0;
filename mylog "/C:/&run._test.log";
proc printto file=mylog new; 
run; /* open and start keep log */
%global ERR_LINE WARN_LINE;
data one;
input NAME $ SEX $ AGE Height WEIGHT;
datalines;
STEVE M 41 74 170
ROCKY M 42 68 166
KURT M 39 72 167
DEBORAH F 30 66 124
JACQUELI F 33 66 115
;
run;
/*added coded only to test error and warning msg*/
proc sql;
        connect to oracle as EXT1 (user="&User." orapw="&OraPw." path="&Path.");
            create table work.abc as
                Select * from connection to EXT1
(select * from emp
);
disconnect from ext1;
quit;

%let OutPut=/C:/;
ods tagsets.excelxp FILE = "&Output/Test_&run.xls"
style=analysis
	options (embedded_titles='yes'
			 embedded_footnotes='no'
			 orientation='landscape'
			 fittopage='yes'
			 missing_align='center'
			 autofit_height='yes'
			 autofilter='yes'
			 row_repeat='1'
			 sheet_name='Data'
			 sheet_interval='None');
proc print data= one ;
   title "test Output" ;
run;
ods tagsets.excelxp close;			 
 		 
%let myrc = &syscc;
proc printto log=log; run; /* close the log file */
/* checking the log */
*filename msg '/proj/sastmp/pvdm/99_TEST_QC/help.txt';
data _null_;
retain count_warn 0;
infile mylog end=eov;
***file msg;
input a_line $2000;    /* adapt to max log line */
if index(a_line, 'ERROR') then 
   call symput('ERR_LINE', trim(a_line));
if index(a_line,'Warning') then count_warn +1;
if eov then 
   call symput('Warn_line', cat('there are ',left(count_warn), '  warnings'));
run;
*Begin email code;
%put "&warn_line.";
%put "&err_line.";
%macro check;
%if %eval(&myrc) LE 4 %then %do;
FILENAME myemail2 EMAIL from=("abc@gmail.com")
 to=("abc@gmail.com")
 Subject = "SAS without any error"
  Attach = ("/C:/Test_&run..xls"
			"/C:/&run._test.log");
data _null_;
file myemail2;
Put "Dear X";
put "  ";
put "Report with no error";
run; 
%end;
%else %do;
 FILENAME myemail2 EMAIL from=("abc@gmail.com")
 to=("abc@gmail.com")
 Subject = "SAS with error"
 Attach = ("/C:/&run._test.log");
data _null_;
file myemail2;
Put "Dear X";
put  "&warn_line.";
put  "&err_line.";
put "Report with error.";
run; 
%end;
%mend check;
%check;

Please have a look .

Shmuel
Garnet | Level 18

1) Change line:

   

proc printto log=log; run; /* close the log file */

  into   

   

proc printto; run; /* close the log file */

 

2)  Checking the log:
     As there is a check for strings "ERROR" and "Warning" - I hope you may have them in log, given by sas only.

 

I hope that will finally give you the desired output.

Abraham
Obsidian | Level 7

Thanks Shmuel for your great help and guidance. The issue is still there.

 

I will try with some other program.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 18 replies
  • 4975 views
  • 5 likes
  • 3 in conversation