<?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: Stop proceeding the rest of the program if certain condition is met. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Stop-proceeding-the-rest-of-the-program-if-certain-condition-is/m-p/153190#M262636</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1.The &lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000210903.htm" title="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000210903.htm"&gt;exist() data step function&lt;/A&gt; judges the existence of a dataset without unnecessarily accessing data (especially when the dataset is huge).&lt;/P&gt;&lt;P&gt;2.To enable data step functions or routines in a macro, simply enclose it with &lt;A href="http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/viewer.htm#z3514sysfunc.htm" title="http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/viewer.htm#z3514sysfunc.htm"&gt;%sysfunc()&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;3. If you need to store the existence state, use %global statement to declare a global variable and use %let to assign value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The above concepts are demonstrated in the following test code. You can change it for your use. Hope this helps&lt;/P&gt;&lt;P&gt;Bill&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: green; background: white;"&gt;/* data A1 does not exist while A2 exists */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: navy; background: white;"&gt;data&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: black; background: white;"&gt; A2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN lang="EN-US" style="font-family: Consolas; color: blue; background: white;"&gt;input&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: black; background: white;"&gt; X @@;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN lang="EN-US" style="font-family: Consolas; color: blue; background: white;"&gt;datalines&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: black; background: #FFFFC0;"&gt;1 2&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: blue; background: white;"&gt;run&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: green; background: white;"&gt;/* conditional execution */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: navy; background: white;"&gt;%macro&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: black; background: white;"&gt; Conditional();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN lang="EN-US" style="font-family: Consolas; color: green; background: white;"&gt;/* get existence directly */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN lang="EN-US" style="font-family: Consolas; color: blue; background: white;"&gt;%if&lt;/SPAN&gt; &lt;SPAN lang="EN-US" style="font-family: Consolas; color: blue; background: white;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: black; background: white;"&gt;(exist(A1)) &lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: blue; background: white;"&gt;%then&lt;/SPAN&gt; &lt;SPAN lang="EN-US" style="font-family: Consolas; color: blue; background: white;"&gt;%do&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN lang="EN-US" style="font-family: Consolas; color: blue; background: white;"&gt;%put&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: black; background: white;"&gt; execute code here when A1 exists;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN lang="EN-US" style="font-family: Consolas; color: blue; background: white;"&gt;%end&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN lang="EN-US" style="font-family: Consolas; color: blue; background: white;"&gt;%else&lt;/SPAN&gt; &lt;SPAN lang="EN-US" style="font-family: Consolas; color: blue; background: white;"&gt;%do&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN lang="EN-US" style="font-family: Consolas; color: blue; background: white;"&gt;%put&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: black; background: white;"&gt; execute code here when A1 does not exist;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN lang="EN-US" style="font-family: Consolas; color: blue; background: white;"&gt;%end&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN lang="EN-US" style="font-family: Consolas; color: green; background: white;"&gt;/* store existence into a macro variable for further use */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN lang="EN-US" style="font-family: Consolas; color: blue; background: white;"&gt;%global&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: black; background: white;"&gt; exist2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN lang="EN-US" style="font-family: Consolas; color: blue; background: white;"&gt;%let&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: black; background: white;"&gt; exist2= &lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: blue; background: white;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: black; background: white;"&gt;(exist(A2)); &lt;SPAN style="color: #008000; font-family: Consolas; background-color: #ffffff;"&gt;/* enclose &lt;SPAN style="color: #008000; font-family: Consolas; background-color: #ffffff;"&gt;to-be-resolved&lt;/SPAN&gt; functions with %sysfunc() */&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN lang="EN-US" style="font-family: Consolas; color: blue; background: white;"&gt;%if&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: black; background: white;"&gt; &amp;amp;exist2 &lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: blue; background: white;"&gt;%then&lt;/SPAN&gt; &lt;SPAN lang="EN-US" style="font-family: Consolas; color: blue; background: white;"&gt;%do&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN lang="EN-US" style="font-family: Consolas; color: blue; background: white;"&gt;%put&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: black; background: white;"&gt; execute code here when A2 exists;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN lang="EN-US" style="font-family: Consolas; color: blue; background: white;"&gt;%end&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN lang="EN-US" style="font-family: Consolas; color: blue; background: white;"&gt;%else&lt;/SPAN&gt; &lt;SPAN lang="EN-US" style="font-family: Consolas; color: blue; background: white;"&gt;%do&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN lang="EN-US" style="font-family: Consolas; color: blue; background: white;"&gt;%put&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: black; background: white;"&gt; execute code herewhen A2 does not exist;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN lang="EN-US" style="font-family: Consolas; color: blue; background: white;"&gt;%end&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: navy; background: white;"&gt;%mend&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: black; background: white;"&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: green; background: white;"&gt;/* execute */&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: black; background: white;"&gt;%&lt;STRONG&gt;&lt;EM&gt;Conditional&lt;/EM&gt;&lt;/STRONG&gt;();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: green; background: white;"&gt;/* &lt;SPAN style="color: #008000; font-family: Consolas; background-color: #ffffff;"&gt;existence of A2 is stored &lt;/SPAN&gt;*/&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: blue; background: white;"&gt;%put&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: black; background: white;"&gt; exist2=&amp;amp;exist2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: black; background: white;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 27 Jan 2014 16:15:41 GMT</pubDate>
    <dc:creator>bill0101</dc:creator>
    <dc:date>2014-01-27T16:15:41Z</dc:date>
    <item>
      <title>Stop proceeding the rest of the program if certain condition is met.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Stop-proceeding-the-rest-of-the-program-if-certain-condition-is/m-p/153187#M262633</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Data Code1;&lt;/P&gt;&lt;P&gt;Set Test1;&lt;/P&gt;&lt;P&gt;Run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data Code2;&lt;/P&gt;&lt;P&gt;Set Test2;&lt;/P&gt;&lt;P&gt;Run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data Code3;&lt;/P&gt;&lt;P&gt;Set Test3;&lt;/P&gt;&lt;P&gt;Run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want the rest of the program to stop running if dataset Code1 is empty. Any help with this?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Jan 2014 07:50:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Stop-proceeding-the-rest-of-the-program-if-certain-condition-is/m-p/153187#M262633</guid>
      <dc:creator>sasthebest</dc:creator>
      <dc:date>2014-01-27T07:50:51Z</dc:date>
    </item>
    <item>
      <title>Re: Stop proceeding the rest of the program if certain condition is met.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Stop-proceeding-the-rest-of-the-program-if-certain-condition-is/m-p/153188#M262634</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: navy; background: white; font-size: 10pt; font-family: Consolas;"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: Consolas;"&gt; &lt;STRONG&gt;&lt;EM&gt;execute&lt;/EM&gt;&lt;/STRONG&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: Consolas;"&gt;Data Code1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: Consolas;"&gt;Set test1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: Consolas;"&gt;Run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: Consolas;"&gt;proc sql;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: Consolas;"&gt;select count(*) into :Count from code1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: Consolas;"&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; background: white; color: blue; font-family: Consolas;"&gt;%if&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: Consolas;"&gt; &amp;amp;count&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="color: teal; background: white; font-size: 10pt; font-family: Consolas;"&gt;&lt;STRONG&gt;0&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="font-size: 10pt; background: white; color: blue; font-family: Consolas;"&gt;%then&lt;/SPAN&gt; &lt;SPAN style="font-size: 10pt; background: white; color: blue; font-family: Consolas;"&gt;%do&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: Consolas;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; background: white; color: blue; font-family: Consolas;"&gt;%put&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: Consolas;"&gt; execute further;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: Consolas;"&gt;Data Code2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: Consolas;"&gt;Set Test2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: Consolas;"&gt;Run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: Consolas;"&gt;Data Code3;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: Consolas;"&gt;Set Test3;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: Consolas;"&gt;Run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; background: white; color: blue; font-family: Consolas;"&gt;%end&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: Consolas;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; background: white; color: blue; font-family: Consolas;"&gt;%else&lt;/SPAN&gt; &lt;SPAN style="font-size: 10pt; background: white; color: blue; font-family: Consolas;"&gt;%put&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: Consolas;"&gt; exit;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: navy; background: white; font-size: 10pt; font-family: Consolas;"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: Consolas;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: Consolas;"&gt;%&lt;STRONG&gt;&lt;EM&gt;execute&lt;/EM&gt;&lt;/STRONG&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Jan 2014 09:39:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Stop-proceeding-the-rest-of-the-program-if-certain-condition-is/m-p/153188#M262634</guid>
      <dc:creator>pradeepalankar</dc:creator>
      <dc:date>2014-01-27T09:39:08Z</dc:date>
    </item>
    <item>
      <title>Re: Stop proceeding the rest of the program if certain condition is met.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Stop-proceeding-the-rest-of-the-program-if-certain-condition-is/m-p/153189#M262635</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would add one line, and change one line:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data Code1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if _n_=1 and done then call execute('endsas;');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set Test1 end=done;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The rest of the program doesn't have to change.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note that this will close out any interactive use of SAS, such as an Enterprise Guide session.&amp;nbsp; So it is most appropriate for batch jobs.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Jan 2014 13:59:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Stop-proceeding-the-rest-of-the-program-if-certain-condition-is/m-p/153189#M262635</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2014-01-27T13:59:33Z</dc:date>
    </item>
    <item>
      <title>Re: Stop proceeding the rest of the program if certain condition is met.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Stop-proceeding-the-rest-of-the-program-if-certain-condition-is/m-p/153190#M262636</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1.The &lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000210903.htm" title="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000210903.htm"&gt;exist() data step function&lt;/A&gt; judges the existence of a dataset without unnecessarily accessing data (especially when the dataset is huge).&lt;/P&gt;&lt;P&gt;2.To enable data step functions or routines in a macro, simply enclose it with &lt;A href="http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/viewer.htm#z3514sysfunc.htm" title="http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/viewer.htm#z3514sysfunc.htm"&gt;%sysfunc()&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;3. If you need to store the existence state, use %global statement to declare a global variable and use %let to assign value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The above concepts are demonstrated in the following test code. You can change it for your use. Hope this helps&lt;/P&gt;&lt;P&gt;Bill&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: green; background: white;"&gt;/* data A1 does not exist while A2 exists */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: navy; background: white;"&gt;data&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: black; background: white;"&gt; A2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN lang="EN-US" style="font-family: Consolas; color: blue; background: white;"&gt;input&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: black; background: white;"&gt; X @@;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN lang="EN-US" style="font-family: Consolas; color: blue; background: white;"&gt;datalines&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: black; background: #FFFFC0;"&gt;1 2&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: blue; background: white;"&gt;run&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: green; background: white;"&gt;/* conditional execution */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: navy; background: white;"&gt;%macro&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: black; background: white;"&gt; Conditional();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN lang="EN-US" style="font-family: Consolas; color: green; background: white;"&gt;/* get existence directly */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN lang="EN-US" style="font-family: Consolas; color: blue; background: white;"&gt;%if&lt;/SPAN&gt; &lt;SPAN lang="EN-US" style="font-family: Consolas; color: blue; background: white;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: black; background: white;"&gt;(exist(A1)) &lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: blue; background: white;"&gt;%then&lt;/SPAN&gt; &lt;SPAN lang="EN-US" style="font-family: Consolas; color: blue; background: white;"&gt;%do&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN lang="EN-US" style="font-family: Consolas; color: blue; background: white;"&gt;%put&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: black; background: white;"&gt; execute code here when A1 exists;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN lang="EN-US" style="font-family: Consolas; color: blue; background: white;"&gt;%end&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN lang="EN-US" style="font-family: Consolas; color: blue; background: white;"&gt;%else&lt;/SPAN&gt; &lt;SPAN lang="EN-US" style="font-family: Consolas; color: blue; background: white;"&gt;%do&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN lang="EN-US" style="font-family: Consolas; color: blue; background: white;"&gt;%put&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: black; background: white;"&gt; execute code here when A1 does not exist;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN lang="EN-US" style="font-family: Consolas; color: blue; background: white;"&gt;%end&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN lang="EN-US" style="font-family: Consolas; color: green; background: white;"&gt;/* store existence into a macro variable for further use */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN lang="EN-US" style="font-family: Consolas; color: blue; background: white;"&gt;%global&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: black; background: white;"&gt; exist2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN lang="EN-US" style="font-family: Consolas; color: blue; background: white;"&gt;%let&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: black; background: white;"&gt; exist2= &lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: blue; background: white;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: black; background: white;"&gt;(exist(A2)); &lt;SPAN style="color: #008000; font-family: Consolas; background-color: #ffffff;"&gt;/* enclose &lt;SPAN style="color: #008000; font-family: Consolas; background-color: #ffffff;"&gt;to-be-resolved&lt;/SPAN&gt; functions with %sysfunc() */&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN lang="EN-US" style="font-family: Consolas; color: blue; background: white;"&gt;%if&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: black; background: white;"&gt; &amp;amp;exist2 &lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: blue; background: white;"&gt;%then&lt;/SPAN&gt; &lt;SPAN lang="EN-US" style="font-family: Consolas; color: blue; background: white;"&gt;%do&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN lang="EN-US" style="font-family: Consolas; color: blue; background: white;"&gt;%put&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: black; background: white;"&gt; execute code here when A2 exists;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN lang="EN-US" style="font-family: Consolas; color: blue; background: white;"&gt;%end&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN lang="EN-US" style="font-family: Consolas; color: blue; background: white;"&gt;%else&lt;/SPAN&gt; &lt;SPAN lang="EN-US" style="font-family: Consolas; color: blue; background: white;"&gt;%do&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN lang="EN-US" style="font-family: Consolas; color: blue; background: white;"&gt;%put&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: black; background: white;"&gt; execute code herewhen A2 does not exist;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN lang="EN-US" style="font-family: Consolas; color: blue; background: white;"&gt;%end&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: navy; background: white;"&gt;%mend&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: black; background: white;"&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: green; background: white;"&gt;/* execute */&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: black; background: white;"&gt;%&lt;STRONG&gt;&lt;EM&gt;Conditional&lt;/EM&gt;&lt;/STRONG&gt;();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: green; background: white;"&gt;/* &lt;SPAN style="color: #008000; font-family: Consolas; background-color: #ffffff;"&gt;existence of A2 is stored &lt;/SPAN&gt;*/&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: blue; background: white;"&gt;%put&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: black; background: white;"&gt; exist2=&amp;amp;exist2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-family: Consolas; color: black; background: white;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Jan 2014 16:15:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Stop-proceeding-the-rest-of-the-program-if-certain-condition-is/m-p/153190#M262636</guid>
      <dc:creator>bill0101</dc:creator>
      <dc:date>2014-01-27T16:15:41Z</dc:date>
    </item>
    <item>
      <title>Re: Stop proceeding the rest of the program if certain condition is met.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Stop-proceeding-the-rest-of-the-program-if-certain-condition-is/m-p/153191#M262637</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would first develop the code and then wrap a macro with a %goto statement around it. Something like below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro wrapper;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &amp;lt;sas code&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; %if &amp;lt;condition&amp;gt; %goto exit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &amp;lt;more SAS code&amp;gt;&lt;/P&gt;&lt;P&gt;%exit: &lt;BR /&gt;%mend wrapper;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Jan 2014 20:25:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Stop-proceeding-the-rest-of-the-program-if-certain-condition-is/m-p/153191#M262637</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2014-01-27T20:25:54Z</dc:date>
    </item>
    <item>
      <title>Re: Stop proceeding the rest of the program if certain condition is met.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Stop-proceeding-the-rest-of-the-program-if-certain-condition-is/m-p/153192#M262638</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I like the use of data step functions, since they are as efficient as it can be. And wrapped into a macro, it can be as flexible that you want.&lt;/P&gt;&lt;P&gt;But if "is empty" means exists with no rows, perhaps you need to use the ATTRN() function instead.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Jan 2014 20:53:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Stop-proceeding-the-rest-of-the-program-if-certain-condition-is/m-p/153192#M262638</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2014-01-27T20:53:01Z</dc:date>
    </item>
  </channel>
</rss>

