<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to create an error email if report fails? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-an-error-email-if-report-fails/m-p/848406#M335423</link>
    <description>&lt;P&gt;But of course if &amp;amp;SYSCC=0 that doesn't mean your results are correct. (couldn't find a maxim for that : )&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm assuming the check on the missing &amp;amp;Y is a check for some logical error in the data (e.g. an implausible value), which does not result in a syntax error.&amp;nbsp; Of course, if assertions are added to detect such implausible values, they would also result in SYSCC being set.&lt;/P&gt;</description>
    <pubDate>Wed, 07 Dec 2022 18:45:55 GMT</pubDate>
    <dc:creator>Quentin</dc:creator>
    <dc:date>2022-12-07T18:45:55Z</dc:date>
    <item>
      <title>How to create an error email if report fails?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-an-error-email-if-report-fails/m-p/848335#M335397</link>
      <description>&lt;P&gt;Below is the following log with my error:ERROR: &lt;FONT size="2"&gt;&lt;EM&gt;A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was:&amp;nbsp;&amp;amp;syscc&amp;lt;20 and &amp;amp;y = 0&amp;nbsp;&lt;/EM&gt;&lt;/FONT&gt;&lt;FONT size="2"&gt;&lt;EM&gt;ERROR: The macro SEND_EMAIL will stop executing. &lt;/EM&gt;I am creating two proc reports and sending out the tables in an email to my customer. I need to solve for having SAS generate an email if for some reson this report errors out or doen't run, so that I am aware there is an issue with the report. The code I am receiving the error on is lines 167-173. Can some help me understand what this code and error are telling me? I am not expereinced with macros and need additional assistance.&amp;nbsp;&lt;/FONT&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
38          value paidf .='0' other=[comma10.];
NOTE: Format PAIDF is already on the library WORK.FORMATS.
NOTE: Format PAIDF has been output.
39         run;

NOTE: PROCEDURE FORMAT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

40         
41         %macro hex2(n);
42         	%local digits n1 n2;
43         	%let digits = 0123456789ABCDEF;
44         	%let n1 = %substr(&amp;amp;digits, &amp;amp;n / 16 + 1, 1);
45         	%let n2 = %substr(&amp;amp;digits, &amp;amp;n - &amp;amp;n / 16 * 16 + 1, 1);
46         	&amp;amp;n1&amp;amp;n2
47         %mend hex2;
2 The SAS System                                                                                     16:22 Tuesday, December 6, 2022

48         
49         %macro RGB(r,g,b);
50         	%cmpres(CX%hex2(&amp;amp;r)%hex2(&amp;amp;g)%hex2(&amp;amp;b))
51         %mend RGB;
52         
53         /*%let font2 = wh;
54         %let fonttype = Arial;*/
55         
56         /*%let worddt= %sysfunc(today(), worddate20.);*/
57         
58         filename mymail clear;
NOTE: Fileref MYMAIL has been deassigned.
59         title;
60         footnote;
61         filename mymail email
62            Subject = "AEP Sales YoY Comparison"
63            sender=("email.email@bcbsfl.com")
64         /*
64       ! To=("email.email@bcbsfl.com")
65        From = ("email.email@bcbsfl.com")
66            CC = ("email.email@bcbsfl.com")
67      
69             content_type="text/html";
70         
71            ods msoffice2k file=mymail rs=none style=htmlblue options(pagebreak="no");
NOTE: Writing MSOFFICE2K Body file: MYMAIL
72            options nocenter;
73         
74         /*ods excel file="/u/&amp;amp;sysuserid./Daily RTS Summary.xlsx"*/
75         
76         /* options (autofilter="all" sheet_name='Broker Mngr RTS Summary' sheet_interval="none" ) ; */
77         
78         title1 j=l h=2.5 color=black "Hello,";
79             title2 j=l h=2.5 color=black "The below tables include summaries of AEP Sales YoY Comparison YTD for AEP 2023 and AEP
79       !  2022 by date and channel.
80         									Please do not hesitate to reach out if you have any questions.";
81             title3 j=l h=2.5 color=black "Thank you." ;
82         
83         proc report data = OUTPUT2 nowd split='|'
84         style(header) = [font=("Arial",10.0pt) vjust=middle just=center background=%RGB(0,145,204) foreground=whitesmoke
84       ! font_weight=bold]
85         style(column) = [font=("Arial",8.58pt) bordercolor=%RGB(242,242,242) ];
86         column Channel '2022'n '2021'n Difference PERCENT_CHANGE ;
87         
88         define Channel / 'Channel' order=data;
89         define '2022'n / sum "AEP Sales | 2023" style(column)={vjust=c just=c cellwidth = 1in} order=data;
90         define '2021'n / sum "AEP Sales | 2022" style(column)={vjust=c just=c cellwidth = 1in} order=data;
91         define Difference / "YOY | Difference" style(column)={vjust=c just=c cellwidth = 1in} order=data;
92         define PERCENT_CHANGE / '% Change' format=percent8.2;
93         
94         /*rbreak after / summarize style=[fontweight=bold] ;*/
95         
96         compute before _page_/style=[font=("Arial",12.5pt) vjust=middle just=center background=whitesmoke
96       ! foreground=%RGB(0,145,204) font_weight=bold borderbottomcolor=%RGB(242,242,242)];
97         		 line 'AEP Sales YoY Comparison' ; endcomp;
98         
3 The SAS System                                                                                     16:22 Tuesday, December 6, 2022

99         compute Channel;
100        	I + 1;
101        	if mod(i,2) eq 1 then
102        	call define(_row_, "style", "style=[background=%RGB(230,230,230)]");
103        endcomp;
104        
105        /*compute after; Channel = 'Total'; call define(_row_,'style','style={backgroundcolor=lightgray foreground=black
105      ! font_weight=bold}'); endcomp; */
106        
107        compute PERCENT_CHANGE;'% change'n=Difference.sum/'2021'n.sum ; endcomp;
108        
109         run;

NOTE: There were 11 observations read from the data set WORK.OUTPUT2.
NOTE: At least one W.D format was too small for the number to be printed. The decimal may be shifted by the "BEST" format.
NOTE: PROCEDURE REPORT used (Total process time):
      real time           0.08 seconds
      cpu time            0.02 seconds
      

110        Title;
111        
112        proc report data = OUTPUT3 nowd split='|'
113        style(header) = [font=("Arial",10.0pt) vjust=middle just=center background=%RGB(0,145,204) foreground=whitesmoke
113      ! font_weight=bold]
114        style(column) = [font=("Arial",8.58pt) bordercolor=%RGB(242,242,242) ];
115        column 'Submit Date'n '2022'n '2021'n Difference PERCENT_CHANGE ;
116        
117        define 'Submit Date'n / "Submit Date" order=data;
118        define '2022'n / sum "AEP Sales | 2023" style(column)={vjust=c just=c cellwidth = 1in} order=data;
119        define '2021'n / sum "AEP Sales | 2022" style(column)={vjust=c just=c cellwidth = 1in} order=data;
120        define Difference / "YOY | Difference" style(column)={vjust=c just=c cellwidth = 1in} order=data;
121        define PERCENT_CHANGE / '% Change' format=percent8.2;
122        
123        /*rbreak after / summarize style=[fontweight=bold] ;*/
124        
125        compute before _page_/style=[font=("Arial",12.5pt) vjust=middle just=center background=whitesmoke
125      ! foreground=%RGB(0,145,204) font_weight=bold borderbottomcolor=%RGB(242,242,242)];
126        		 line 'AEP Sales YoY Comparison' ; endcomp;
127        
128        compute 'Submit Date'n;
129        	I + 1;
130        	if mod(i,2) eq 1 then
131        	call define(_row_, "style", "style=[background=%RGB(230,230,230)]");
132        endcomp;
133        
134        /*compute after; 'Submit Date'n = Total; call define(_row_,'style','style={backgroundcolor=lightgray foreground=black
134      ! font_weight=bold}'); endcomp; */
135        
136        compute PERCENT_CHANGE;'% change'n=Difference.sum/'2021'n.sum ; endcomp;
137        
138         run;

NOTE: Missing values were generated as a result of performing an operation on missing values.
      Each place is given by: (Number of times) at (Line):(Column).
      9 at 1:27   
NOTE: There were 67 observations read from the data set WORK.OUTPUT3.
NOTE: At least one W.D format was too small for the number to be printed. The decimal may be shifted by the "BEST" format.
4 The SAS System                                                                                     16:22 Tuesday, December 6, 2022

NOTE: PROCEDURE REPORT used (Total process time):
      real time           0.28 seconds
      cpu time            0.07 seconds
      

139        
140         %macro send_email;
141        %if &amp;amp;syscc&amp;lt;20 and &amp;amp;y = 0 %then %do;
142        
143        title;
144        footnote;
145        filename myemail email
146           Subject = " ERROR: AEP Sales YoY Comparison"
147        	sender=("email.email@bcbsfl.com")
148        	To = ("email.email@bcbsfl.com")
149        	From = ("email.email@bcbsfl.com")
150        	CC = ("email.email@bcbsfl.com")
151            content_type="text/html";
152        
153        data _null_;
154        file myemail;
155        put '&amp;lt;body style=font-size:11pt;font-family:Times New Roman&amp;gt;';
156        put " &amp;lt;p&amp;gt;Hello,";
157        put '&amp;lt;/p&amp;gt;';
158        put "&amp;lt;p&amp;gt;There is an error in AEP Sales YoY Comparison.";
159        put '&amp;lt;br&amp;gt;';
160        put '&amp;lt;br&amp;gt;';
161        put "&amp;lt;p&amp;gt;";
162        put '&amp;lt;br&amp;gt;';
163        
164        
165        run;
166        
167        %end;
168        %else %if &amp;amp;syscc&amp;lt;20 and &amp;amp;y&amp;gt; 0 %then %do;
169        
170        %reps2;
171        %end;
172        %mend send_email;
173        %send_email;
WARNING: Apparent symbolic reference Y not resolved.
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: 
       &amp;amp;syscc&amp;lt;20 and &amp;amp;y = 0 
ERROR: The macro SEND_EMAIL will stop executing.
174        
175        
176        GOPTIONS NOACCESSIBLE;
177        %LET _CLIENTTASKLABEL=;
178        %LET _CLIENTPROCESSFLOWNAME=;
179        %LET _CLIENTPROJECTPATH=;
180        %LET _CLIENTPROJECTPATHHOST=;
181        %LET _CLIENTPROJECTNAME=;
182        %LET _SASPROGRAMFILE=;
183        %LET _SASPROGRAMFILEHOST=;
184        
185        ;*';*";*/;quit;run;
186        ODS _ALL_ CLOSE;
Message sent
5 The SAS System                                                                                     16:22 Tuesday, December 6, 2022

      To:          
      Cc:          "email.email@bcbsfl.com"
      Bcc:         
      Subject:     AEP Sales YoY Comparison
      Attachments: 
187        
188        
189        QUIT; RUN;
190        
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Dec 2022 13:26:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-an-error-email-if-report-fails/m-p/848335#M335397</guid>
      <dc:creator>LMSSAS</dc:creator>
      <dc:date>2022-12-07T13:26:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to create an error email if report fails?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-an-error-email-if-report-fails/m-p/848338#M335399</link>
      <description>&lt;P&gt;This warning (and subsequent errors) are triggered because you have not created a macro variable named Y:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;WARNING: Apparent symbolic reference Y not resolved.
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: 
       &amp;amp;syscc&amp;lt;20 and &amp;amp;y = 0 
ERROR: The macro SEND_EMAIL will stop executing.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Your macro send_email references the macro variable Y:&lt;/P&gt;
&lt;PRE&gt;140         %macro send_email;
141        %if &amp;amp;syscc&amp;lt;20 and &amp;amp;y = 0 %then %do;&lt;/PRE&gt;
&lt;P&gt;In order to debug this, you'll need to understand the intent of that %IF statement.&amp;nbsp; What is the purpose of making the email conditional on &amp;amp;y=0 ?&amp;nbsp; What is the meaning of the macro variable Y?&amp;nbsp; Where should the Y macro variable have been created, and why doesn't it exist?&amp;nbsp; You might also consider changing the name of the macro variable Y to something more descriptive.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 13:51:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-an-error-email-if-report-fails/m-p/848338#M335399</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2022-12-07T13:51:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to create an error email if report fails?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-an-error-email-if-report-fails/m-p/848374#M335418</link>
      <description>&lt;P&gt;No need to check for anything but &amp;amp;SYSCC. As soon as SYSCC is not zero, your code did not run cleanly.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 17:20:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-an-error-email-if-report-fails/m-p/848374#M335418</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-12-07T17:20:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to create an error email if report fails?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-an-error-email-if-report-fails/m-p/848406#M335423</link>
      <description>&lt;P&gt;But of course if &amp;amp;SYSCC=0 that doesn't mean your results are correct. (couldn't find a maxim for that : )&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm assuming the check on the missing &amp;amp;Y is a check for some logical error in the data (e.g. an implausible value), which does not result in a syntax error.&amp;nbsp; Of course, if assertions are added to detect such implausible values, they would also result in SYSCC being set.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 18:45:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-an-error-email-if-report-fails/m-p/848406#M335423</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2022-12-07T18:45:55Z</dc:date>
    </item>
  </channel>
</rss>

