<?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 Conditional logic only partially honored using email attachments in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Conditional-logic-only-partially-honored-using-email-attachments/m-p/59785#M12942</link>
    <description>I have the following data step that I am executing.  I only want to execute it if the variable PCTFREE is below 8 percent.  I have echoed the contents of PCTFREE and it is currently resolving to a numeric character of 16.  Part of the code does not execute however, the attachment is still honored and sent via email.&lt;BR /&gt;
I do not want any of the code executed if condition is not met.  Is this a bug or is this a bug in my coding?&lt;BR /&gt;
&lt;BR /&gt;
DATA _NULL_;                                                 &lt;BR /&gt;
  SET VIRB;                                                  &lt;BR /&gt;
  IF PCTFREE &amp;lt; 8 THEN DO;                                    &lt;BR /&gt;
  HEADING = 'THE PROD CDAM FILES ARE ONLY '||                &lt;BR /&gt;
  TRIM(LEFT(PCTFREE))||' PERCENT FREE';                      &lt;BR /&gt;
 /****************************************************************************/  &lt;BR /&gt;
 /* THIS PORTION SENDS AN EMAIL TO WARN OF LOW THRESHOLD */  &lt;BR /&gt;
 /****************************************************************************/  &lt;BR /&gt;
  FILE OUTBOX EMAIL                                          &lt;BR /&gt;
  TO='JOHNDOE@MYEMAILBOX.COM'                        &lt;BR /&gt;
  SUBJECT='THE SUBJECT LINE SHOULD GET OVERWRITTEN BELOW'    &lt;BR /&gt;
  TYPE='TEXT/HTML'                                           &lt;BR /&gt;
  ATTACH=('MY.OUTPUT.HTML' NAME='MYREPORT' EXT='HTM');   &lt;BR /&gt;
  PUT '!EM_SUBJECT!' HEADING;                                &lt;BR /&gt;
  PUT 'OUT OF A TOTAL OF ' TOTCYL ' CYLINDERS, ONLY ' FREECYL&lt;BR /&gt;
  ' CYLINDERS REMAIN ';                                      &lt;BR /&gt;
  END;                                                       &lt;BR /&gt;
  RUN;</description>
    <pubDate>Wed, 05 Nov 2008 15:45:47 GMT</pubDate>
    <dc:creator>HoustonGSC</dc:creator>
    <dc:date>2008-11-05T15:45:47Z</dc:date>
    <item>
      <title>Conditional logic only partially honored using email attachments</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-logic-only-partially-honored-using-email-attachments/m-p/59785#M12942</link>
      <description>I have the following data step that I am executing.  I only want to execute it if the variable PCTFREE is below 8 percent.  I have echoed the contents of PCTFREE and it is currently resolving to a numeric character of 16.  Part of the code does not execute however, the attachment is still honored and sent via email.&lt;BR /&gt;
I do not want any of the code executed if condition is not met.  Is this a bug or is this a bug in my coding?&lt;BR /&gt;
&lt;BR /&gt;
DATA _NULL_;                                                 &lt;BR /&gt;
  SET VIRB;                                                  &lt;BR /&gt;
  IF PCTFREE &amp;lt; 8 THEN DO;                                    &lt;BR /&gt;
  HEADING = 'THE PROD CDAM FILES ARE ONLY '||                &lt;BR /&gt;
  TRIM(LEFT(PCTFREE))||' PERCENT FREE';                      &lt;BR /&gt;
 /****************************************************************************/  &lt;BR /&gt;
 /* THIS PORTION SENDS AN EMAIL TO WARN OF LOW THRESHOLD */  &lt;BR /&gt;
 /****************************************************************************/  &lt;BR /&gt;
  FILE OUTBOX EMAIL                                          &lt;BR /&gt;
  TO='JOHNDOE@MYEMAILBOX.COM'                        &lt;BR /&gt;
  SUBJECT='THE SUBJECT LINE SHOULD GET OVERWRITTEN BELOW'    &lt;BR /&gt;
  TYPE='TEXT/HTML'                                           &lt;BR /&gt;
  ATTACH=('MY.OUTPUT.HTML' NAME='MYREPORT' EXT='HTM');   &lt;BR /&gt;
  PUT '!EM_SUBJECT!' HEADING;                                &lt;BR /&gt;
  PUT 'OUT OF A TOTAL OF ' TOTCYL ' CYLINDERS, ONLY ' FREECYL&lt;BR /&gt;
  ' CYLINDERS REMAIN ';                                      &lt;BR /&gt;
  END;                                                       &lt;BR /&gt;
  RUN;</description>
      <pubDate>Wed, 05 Nov 2008 15:45:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-logic-only-partially-honored-using-email-attachments/m-p/59785#M12942</guid>
      <dc:creator>HoustonGSC</dc:creator>
      <dc:date>2008-11-05T15:45:47Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional logic only partially honored using email attachments</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-logic-only-partially-honored-using-email-attachments/m-p/59786#M12943</link>
      <description>Since your post doesn't contain the full code (maybe due to a bug in the forum...:http://support.sas.com/forums/thread.jspa?threadID=4138&amp;amp;tstart=0), log or sample data, it is hard to see you full problem. If your VIRB table just contain one observation, I would go for macro logic instead, by using %if %then %do etc.&lt;BR /&gt;
&lt;BR /&gt;
/Linus</description>
      <pubDate>Wed, 05 Nov 2008 16:04:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-logic-only-partially-honored-using-email-attachments/m-p/59786#M12943</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2008-11-05T16:04:44Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional logic only partially honored using email attachments</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-logic-only-partially-honored-using-email-attachments/m-p/59787#M12944</link>
      <description>Sorry, I wasn't aware of the bug you described.  Here is the code again using LT instead of the less than sign and removing all slashes.   &lt;BR /&gt;
&lt;BR /&gt;
DATA _NULL_;                                                 &lt;BR /&gt;
  SET VIRB;                                                  &lt;BR /&gt;
  IF PCTFREE LT 8 THEN DO;                                    &lt;BR /&gt;
  HEADING = 'THE PROD CDAM FILES ARE ONLY '||                &lt;BR /&gt;
  TRIM(LEFT(PCTFREE))||' PERCENT FREE';                      &lt;BR /&gt;
  FILE OUTBOX EMAIL                                          &lt;BR /&gt;
  TO='JOHNDOE@MYEMAIL.COM'                        &lt;BR /&gt;
  SUBJECT='THE SUBJECT LINE SHOULD GET OVERWRITTEN BELOW'    &lt;BR /&gt;
  TYPE='HTML'                                           &lt;BR /&gt;
  ATTACH=('MY.OUTPUT.HTML' NAME='MYREPORT' EXT='HTM');   &lt;BR /&gt;
  PUT '!EM_SUBJECT!' HEADING;                                &lt;BR /&gt;
  PUT 'OUT OF A TOTAL OF ' TOTCYL ' CYLINDERS, ONLY ' FREECYL&lt;BR /&gt;
  ' CYLINDERS REMAIN ';                                      &lt;BR /&gt;
  END;                                                       &lt;BR /&gt;
  RUN;</description>
      <pubDate>Wed, 05 Nov 2008 16:17:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-logic-only-partially-honored-using-email-attachments/m-p/59787#M12944</guid>
      <dc:creator>HoustonGSC</dc:creator>
      <dc:date>2008-11-05T16:17:17Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional logic only partially honored using email attachments</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-logic-only-partially-honored-using-email-attachments/m-p/59788#M12945</link>
      <description>What do you mean by "numeric character of 16"? Is PCTFREE a numeric or a character variable? What is not executed (how do you see that)? Please attach a log with a PUTLOG _ALL_; inside your DO-block.&lt;BR /&gt;
&lt;BR /&gt;
/Linus</description>
      <pubDate>Thu, 06 Nov 2008 07:57:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-logic-only-partially-honored-using-email-attachments/m-p/59788#M12945</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2008-11-06T07:57:26Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional logic only partially honored using email attachments</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-logic-only-partially-honored-using-email-attachments/m-p/59789#M12946</link>
      <description>I know that PCTFREE Is a numeric character because I already did a put PCTFREE to the log to verify it was a number.&lt;BR /&gt;
&lt;BR /&gt;
This is the listing of all the variables resulting from the PUT _ALL_ &lt;BR /&gt;
&lt;BR /&gt;
SYSID=PROD _TYPE_=0 _FREQ_=1 STORGRPS=1 VOLUMES=6 FREECYL=14,747 ALLOC=181,849 TOTCYL=196,560 PCTFREE=8 HEADING=  _ERROR_=0 _N_=1&lt;BR /&gt;
&lt;BR /&gt;
All I want to do is check the value of PCTFREE and if it falls below a threshold, then execute the logic.&lt;BR /&gt;
&lt;BR /&gt;
I even tried changing the conditional statement to : &lt;BR /&gt;
IF PCTFREE GT 5 THEN GO TO ALLDONE&lt;BR /&gt;
and I put a label of ALLDONE at the end of the DO loop to see if it would bypass the email logic but it still didn't.  It still executes which is puzzling.</description>
      <pubDate>Thu, 06 Nov 2008 12:48:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-logic-only-partially-honored-using-email-attachments/m-p/59789#M12946</guid>
      <dc:creator>HoustonGSC</dc:creator>
      <dc:date>2008-11-06T12:48:55Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional logic only partially honored using email attachments</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-logic-only-partially-honored-using-email-attachments/m-p/59790#M12947</link>
      <description>I tried to separate the conditional logic and the e-mail sending step into different data steps using a call execute macro call, and I think I got the behavior that you desired:&lt;BR /&gt;
&lt;BR /&gt;
DATA _NULL_; &lt;BR /&gt;
	SET VIRB; &lt;BR /&gt;
	IF age LT 12 THEN DO; &lt;BR /&gt;
		HEADING = 'THE AGE ARE ONLY '|| &lt;BR /&gt;
		TRIM(LEFT(PCTFREE ))||' !!!'; &lt;BR /&gt;
		call execute('%EMAIL('||heading||','||freecyl||','||totcyl||');');&lt;BR /&gt;
	END; &lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
%macro email(heading,freecyl,totcyl);&lt;BR /&gt;
	data _null_;&lt;BR /&gt;
		FILE OUTBOX EMAIL &lt;BR /&gt;
		TO='JOHNDOE@MYEMAIL.COM' &lt;BR /&gt;
		SUBJECT='THE SUBJECT LINE SHOULD GET OVERWRITTEN BELOW' &lt;BR /&gt;
		TYPE='HTML' &lt;BR /&gt;
		ATTACH=('MY.OUTPUT.HTML' NAME='MYREPORT' EXT='TXT'); &lt;BR /&gt;
		PUT "!EM_SUBJECT! &amp;amp;HEADING."; &lt;BR /&gt;
		PUT "OUT OF A TOTAL OF  &amp;amp;TOTCYL CYLINDERS, ONLY &amp;amp;FREECYL CYLINDERS REMAIN "; &lt;BR /&gt;
	run;&lt;BR /&gt;
%mend email;&lt;BR /&gt;
&lt;BR /&gt;
Hope this helps,&lt;BR /&gt;
&lt;BR /&gt;
Linus</description>
      <pubDate>Thu, 06 Nov 2008 14:24:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-logic-only-partially-honored-using-email-attachments/m-p/59790#M12947</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2008-11-06T14:24:01Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional logic only partially honored using email attachments</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-logic-only-partially-honored-using-email-attachments/m-p/59791#M12948</link>
      <description>Linus, I tried your example but when I put the macro after the data step with the conditonal test as in your example, I would get the following error:&lt;BR /&gt;
WARNING: Apparent invocation of macro EMAIL not resolved.&lt;BR /&gt;
&lt;BR /&gt;
If I moved the macro definition to appear before the data step with the conditional test, the sas ran fine however, the email was never sent :&lt;BR /&gt;
&lt;BR /&gt;
MLOGIC(EMAIL):  Beginning execution.                                            &lt;BR /&gt;
MLOGIC(EMAIL):  Parameter PCTFREE has value 8                                   &lt;BR /&gt;
MLOGIC(EMAIL):  Parameter TOTCYL has value 196560                               &lt;BR /&gt;
MLOGIC(EMAIL):  Parameter FREECYL has value 15488                               &lt;BR /&gt;
MPRINT(EMAIL):   DATA _NULL_;                                                   &lt;BR /&gt;
SYMBOLGEN:  Macro variable PCTFREE resolves to 8                                &lt;BR /&gt;
MPRINT(EMAIL):   PUT "!EM_SUBJECT! THE PROD CDAM FILES ARE ONLY 8 PERCENT FREE."&lt;BR /&gt;
SYMBOLGEN:  Macro variable TOTCYL resolves to 196560                            &lt;BR /&gt;
SYMBOLGEN:  Macro variable FREECYL resolves to 15488                            &lt;BR /&gt;
MPRINT(EMAIL):   PUT "OUT OF A TOTAL OF 196560 CYLS, ONLY 15488 CYLS REMAIN.";  &lt;BR /&gt;
MPRINT(EMAIL):   RUN;                                                           &lt;BR /&gt;
MLOGIC(EMAIL):  Ending execution.                                               &lt;BR /&gt;
NOTE: There were 1 observations read from the data set WORK.VIRB.               &lt;BR /&gt;
                                                                                &lt;BR /&gt;
NOTE: CALL EXECUTE generated line.                                              &lt;BR /&gt;
1         + DATA _NULL_;                        &lt;BR /&gt;
PUT "!EM_SUBJECT! THE PROD CDAM FILES ARE ONLY 8 PERCENT FREE.";             &lt;BR /&gt;
PUT  "OUT OF A TOTAL OF 196560 CYLS, ONLY 15488 CYLS REMAIN.";&lt;BR /&gt;
RUN;&lt;BR /&gt;
                                                                               &lt;BR /&gt;
!EM_SUBJECT! THE PROD CDAM FILES ARE ONLY 8 PERCENT FREE.                       &lt;BR /&gt;
OUT OF A TOTAL OF 196560 CYLS, ONLY 15488 CYLS REMAIN.                          &lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
I really appreciate your time and feedback Linus but this is way more convoluted than what I think it should be.  I think I'll forget about the SAS and just use REXX instead.&lt;BR /&gt;
&lt;BR /&gt;
Thanks,&lt;BR /&gt;
Gil.</description>
      <pubDate>Thu, 06 Nov 2008 17:12:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-logic-only-partially-honored-using-email-attachments/m-p/59791#M12948</guid>
      <dc:creator>HoustonGSC</dc:creator>
      <dc:date>2008-11-06T17:12:28Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional logic only partially honored using email attachments</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-logic-only-partially-honored-using-email-attachments/m-p/59792#M12949</link>
      <description>Yes, the macro definition has to be prior to the call. Sorry for that.&lt;BR /&gt;
But I can't see any FILE statement in your LOG, it should appear both in the MPRINT and "NOTE: CALL EXECUTE generated line. " sections right after DATA _NULL_;&lt;BR /&gt;
If there is no FILE statement, there will be no email...&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
/Linus</description>
      <pubDate>Thu, 06 Nov 2008 17:26:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-logic-only-partially-honored-using-email-attachments/m-p/59792#M12949</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2008-11-06T17:26:53Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional logic only partially honored using email attachments</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-logic-only-partially-honored-using-email-attachments/m-p/59793#M12950</link>
      <description>This is what the macro definition is :&lt;BR /&gt;
&lt;BR /&gt;
OPTIONS MPRINT MLOGIC SYMBOLGEN;                                     &lt;BR /&gt;
%MACRO EMAIL(PCTFREE,TOTCYL,FREECYL);                                &lt;BR /&gt;
DATA _NULL_;                                                         &lt;BR /&gt;
&lt;BR /&gt;
  FILE OUTBOX EMAIL                                                  &lt;BR /&gt;
  TO='JOHNDOE@MYEMAIL.COM'                                &lt;BR /&gt;
  TYPE='HTML'                                                   &lt;BR /&gt;
  ATTACH=('MY.FILE.HTML' NAME='MYREPORT' EXT='HTM');           &lt;BR /&gt;
  PUT                                                                &lt;BR /&gt;
  "!EM_SUBJECT! THE PROD CDAM FILES ARE ONLY &amp;amp;PCTFREE PERCENT FREE.";&lt;BR /&gt;
  PUT                                                                &lt;BR /&gt;
  "OUT OF A TOTAL OF &amp;amp;TOTCYL CYLS, ONLY &amp;amp;FREECYL CYLS REMAIN.";      &lt;BR /&gt;
  RUN;                                                               &lt;BR /&gt;
%MEND EMAIL;</description>
      <pubDate>Thu, 06 Nov 2008 17:32:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-logic-only-partially-honored-using-email-attachments/m-p/59793#M12950</guid>
      <dc:creator>HoustonGSC</dc:creator>
      <dc:date>2008-11-06T17:32:32Z</dc:date>
    </item>
  </channel>
</rss>

