<?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 Safely stop Sas execution when condition not satisfied in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Safely-stop-Sas-execution-when-condition-not-satisfied/m-p/647304#M193708</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;what can i put in the &lt;FONT color="#FF0000"&gt;%abend&amp;nbsp;&lt;/FONT&gt; part of the program to safely stop code execution . I do not want any further steps to be executed&lt;/P&gt;
&lt;P&gt;*---------------------------------------------------------------------------------------------------------------*&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro Check(file_upload_date.)&lt;BR /&gt;proc sql;&lt;BR /&gt;create table t1 as&lt;BR /&gt;select max(Response_File_Load_Date) as max_File_Load_Date format=date9. &lt;BR /&gt;into :max_File_Load_Date&lt;BR /&gt;from My_lib.Table1&lt;BR /&gt;/* where dt &amp;lt; today() and flg = 0*/&lt;BR /&gt;;quit;&lt;/P&gt;
&lt;P&gt;%put &amp;amp;max_File_Load_Date.;&lt;/P&gt;
&lt;P&gt;%if &amp;amp;max_File_Load_Date. &amp;gt;= &amp;amp;file_upload_date. %then &lt;FONT color="#FF0000"&gt;%abend;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;%mend;&lt;BR /&gt;%check(&amp;amp;file_upload_date.);&lt;/P&gt;</description>
    <pubDate>Wed, 13 May 2020 04:39:01 GMT</pubDate>
    <dc:creator>dennis_oz</dc:creator>
    <dc:date>2020-05-13T04:39:01Z</dc:date>
    <item>
      <title>Safely stop Sas execution when condition not satisfied</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Safely-stop-Sas-execution-when-condition-not-satisfied/m-p/647304#M193708</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;what can i put in the &lt;FONT color="#FF0000"&gt;%abend&amp;nbsp;&lt;/FONT&gt; part of the program to safely stop code execution . I do not want any further steps to be executed&lt;/P&gt;
&lt;P&gt;*---------------------------------------------------------------------------------------------------------------*&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro Check(file_upload_date.)&lt;BR /&gt;proc sql;&lt;BR /&gt;create table t1 as&lt;BR /&gt;select max(Response_File_Load_Date) as max_File_Load_Date format=date9. &lt;BR /&gt;into :max_File_Load_Date&lt;BR /&gt;from My_lib.Table1&lt;BR /&gt;/* where dt &amp;lt; today() and flg = 0*/&lt;BR /&gt;;quit;&lt;/P&gt;
&lt;P&gt;%put &amp;amp;max_File_Load_Date.;&lt;/P&gt;
&lt;P&gt;%if &amp;amp;max_File_Load_Date. &amp;gt;= &amp;amp;file_upload_date. %then &lt;FONT color="#FF0000"&gt;%abend;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;%mend;&lt;BR /&gt;%check(&amp;amp;file_upload_date.);&lt;/P&gt;</description>
      <pubDate>Wed, 13 May 2020 04:39:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Safely-stop-Sas-execution-when-condition-not-satisfied/m-p/647304#M193708</guid>
      <dc:creator>dennis_oz</dc:creator>
      <dc:date>2020-05-13T04:39:01Z</dc:date>
    </item>
    <item>
      <title>Re: Safely stop Sas execution when condition not satisfied</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Safely-stop-Sas-execution-when-condition-not-satisfied/m-p/647308#M193710</link>
      <description>&lt;P&gt;you can try like below&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro Check(file_upload_date.)
proc sql;
create table t1 as
select max(Response_File_Load_Date) as max_File_Load_Date format=date9.
into :max_File_Load_Date
from My_lib.Table1
/* where dt &amp;lt; today() and flg = 0*/
;quit;

%put &amp;amp;max_File_Load_Date.;

%if &amp;amp;max_File_Load_Date. &amp;gt;= &amp;amp;file_upload_date. %then &lt;FONT color="#FF0000"&gt;%do;
%abort;
%end;&lt;/FONT&gt;
%mend;
%check(&amp;amp;file_upload_date.);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 May 2020 05:46:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Safely-stop-Sas-execution-when-condition-not-satisfied/m-p/647308#M193710</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2020-05-13T05:46:20Z</dc:date>
    </item>
    <item>
      <title>Re: Safely stop Sas execution when condition not satisfied</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Safely-stop-Sas-execution-when-condition-not-satisfied/m-p/647321#M193716</link>
      <description>&lt;P&gt;First of all, you need to make sure that your code works at all. Maxim 2: Read the Log:&lt;/P&gt;
&lt;PRE&gt; ERROR: Symbolic variable name FILE_UPLOAD_DATE. must contain only letters, digits, and underscores.
 ERROR: Invalid macro parameter name FILE_UPLOAD_DATE..  It should be a valid SAS identifier no longer than 32 characters.
 ERROR: A dummy macro will be compiled.
 72         
 73         %macro Check(file_upload_date.)
 74         proc sql;
 75         create table t1 as
 76         select max(Response_File_Load_Date) as max_File_Load_Date format=date9.
 77         into :max_File_Load_Date
 78         from My_lib.Table1
 79         /* where dt &amp;lt; today() and flg = 0*/
 80         ;quit;
 81         %put &amp;amp;max_File_Load_Date.;
 82         %if &amp;amp;max_File_Load_Date. &amp;gt;= &amp;amp;file_upload_date. %then %abend;
 ERROR: Macro keyword ABEND is not yet implemented.
 83         %mend;
&lt;/PRE&gt;
&lt;P&gt;First fix the issue with the invalid macro parameter name.&lt;/P&gt;
&lt;P&gt;Then use a %put statement instead of the (invalid) %abend statement. Testing that will reveal that your comparison will not work as intended because you formatted the macro variable&amp;nbsp;&lt;SPAN&gt;max_File_Load_Date with DATE9.; 01MAY2020 is "smaller" than 30APR2020 in a text comparison. Maxim 28: Macro Variables Need No Formats. The raw numeric values will always work correctly.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Follow Maxim 1 (Read the Documentation) to find out how to abort a SAS session with a macro statement:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=mcrolref&amp;amp;docsetTarget=p0b6jxu7c65h63n1inak5lx7fys2.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;Macro Statements&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 May 2020 06:28:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Safely-stop-Sas-execution-when-condition-not-satisfied/m-p/647321#M193716</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-05-13T06:28:45Z</dc:date>
    </item>
  </channel>
</rss>

