<?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: Within macro, how to stop later procedure one of the internal data file has no observation in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Within-macro-how-to-stop-later-procedure-one-of-the-internal/m-p/367410#M24043</link>
    <description>&lt;P&gt;There's an automatic variable &amp;amp;SQLOBS that SQL produces, showing the number of observations processed.&amp;nbsp; You should be able to condition on that being greater than 0 to control subsequent procedures.&lt;/P&gt;</description>
    <pubDate>Thu, 15 Jun 2017 15:33:59 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2017-06-15T15:33:59Z</dc:date>
    <item>
      <title>Within macro, how to stop later procedure one of the internal data file has no observation</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Within-macro-how-to-stop-later-procedure-one-of-the-internal/m-p/367407#M24042</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using SAS EG to build a macro function.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It reads initial input data line by line (each is an individual spot) and final output is by each spot level.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Some times for one spot, one of the internal data does not have any observation (This spot does not exist in the system in Oracle Database)&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My code looks like this form:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro mymacro;&lt;BR /&gt;OPTIONS NOTES SOURCE SOURCE2 MPRINT MLOGIC MERROR SYMBOLGEN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/* Define&amp;nbsp;the initial input file as well as its structure */&lt;/P&gt;&lt;P&gt;data _null_;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; set Input&amp;nbsp;end=last;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; if last then call symput('nfiles',_n_);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/* Read input data line by line */&lt;/P&gt;&lt;P&gt;%do i=1 %to &amp;amp;nfiles;&lt;/P&gt;&lt;P&gt;data _null_;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;set Input;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;if &amp;amp;i=_n_ then&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;call symput('Spot',Spot);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/* The following reads data from Oracle Database */&amp;nbsp;&lt;/P&gt;&lt;P&gt;Proc Sql;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; connect to oracle (user=..... orapw=..... path=.....);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; create table Supply_&amp;amp;Spot&amp;nbsp;as&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; select * from connection to oracle&lt;/P&gt;&lt;P&gt;(&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;P&gt;);&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; disconnect from Oracle;&lt;/P&gt;&lt;P&gt;Quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/* Sometimes, some specific spots does not exist in the system and I woule like to stop the following procedure if that happens */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data&amp;nbsp;&lt;SPAN&gt;Supply2_&amp;amp;Spot;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Set&amp;nbsp;Supply_&amp;amp;Spot;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;...........;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;...........;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;......&lt;/P&gt;&lt;P&gt;......&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%mymacro;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I am trying to add this procedure after Data I/O from Oracle database:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;%if %sysfunc(exist(Supply_&amp;amp;Spot)) %then&lt;BR /&gt;%do;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;....... (Following procedures ...)&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;%end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;%else %stop; (Is this line correct?)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;But it seems I cannot use this procedure as if a specific spot doesnot exist in the Oracle, it will also return data Supply_&amp;amp;Spot, but has no observations. So that I cannot use 'exist'.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Is there any way to fix it? So that if that dataset has 0 observation, I can stop the process; otherwise, it will continue to run the following procedures. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you! &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2017 15:27:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Within-macro-how-to-stop-later-procedure-one-of-the-internal/m-p/367407#M24042</guid>
      <dc:creator>Crubal</dc:creator>
      <dc:date>2017-06-15T15:27:20Z</dc:date>
    </item>
    <item>
      <title>Re: Within macro, how to stop later procedure one of the internal data file has no observation</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Within-macro-how-to-stop-later-procedure-one-of-the-internal/m-p/367410#M24043</link>
      <description>&lt;P&gt;There's an automatic variable &amp;amp;SQLOBS that SQL produces, showing the number of observations processed.&amp;nbsp; You should be able to condition on that being greater than 0 to control subsequent procedures.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2017 15:33:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Within-macro-how-to-stop-later-procedure-one-of-the-internal/m-p/367410#M24043</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-06-15T15:33:59Z</dc:date>
    </item>
    <item>
      <title>Re: Within macro, how to stop later procedure one of the internal data file has no observation</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Within-macro-how-to-stop-later-procedure-one-of-the-internal/m-p/367476#M24050</link>
      <description>&lt;P&gt;That works. Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2017 19:11:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Within-macro-how-to-stop-later-procedure-one-of-the-internal/m-p/367476#M24050</guid>
      <dc:creator>Crubal</dc:creator>
      <dc:date>2017-06-15T19:11:04Z</dc:date>
    </item>
  </channel>
</rss>

