<?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: SAS DI Check if dataset is empty and abort if not in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/SAS-DI-Check-if-dataset-is-empty-and-abort-if-not/m-p/395887#M12041</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/130025"&gt;@titan31&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;What you describe sounds to me already like a bit too much user written code (like this macro you mention). But not knowing the details below some SAS code which you could run after the error table gets created, either as post code or as a separate user written node.&lt;/P&gt;
&lt;P&gt;If there is a macro for capturing errors but you then only keep those error in a work table and you are not really interested to look at these error records then why don't you just abort the job directly in this macro as soon as it finds the first error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But o.k., here a code sample that aborts the job if&amp;nbsp;table &lt;EM&gt;test&lt;/EM&gt; got any rows.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  if nobs&amp;gt;0 then
    do;
      put 'Table Test has ' nobs 'rows';
      put 'Aborting job';
      abort abend;
    end;
  stop;
  set test nobs=nobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 14 Sep 2017 12:15:48 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2017-09-14T12:15:48Z</dc:date>
    <item>
      <title>SAS DI Check if dataset is empty and abort if not</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/SAS-DI-Check-if-dataset-is-empty-and-abort-if-not/m-p/395401#M12027</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm quite new to SAS and really can't get my head around it's code, so asking here for help. I'm using DI studio.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've a job that is reading an external csv file using file reader, and have a macro created by a colleague that validates the data in this external file and prints out error message to a work table.&lt;/P&gt;&lt;P&gt;What I'd like to do is either on precode of the file reader, or by using another user written code transformation is to read the work table and check if observations exist, and if they do, abort the job. From googling, and between here and stackoverflow,&amp;nbsp;I can find how to read a dataset and count observations but I'm having real difficulty in figuring out how to implement it so any guidance would be really appreciated, or if there are better ways using SAS Di transformations like Conditional Start etc, I'm all ears for those too.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone please help me on this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2017 06:49:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/SAS-DI-Check-if-dataset-is-empty-and-abort-if-not/m-p/395401#M12027</guid>
      <dc:creator>titan31</dc:creator>
      <dc:date>2017-09-13T06:49:38Z</dc:date>
    </item>
    <item>
      <title>Re: SAS DI Check if dataset is empty and abort if not</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/SAS-DI-Check-if-dataset-is-empty-and-abort-if-not/m-p/395461#M12028</link>
      <description>&lt;P&gt;Yes there are.&lt;/P&gt;
&lt;P&gt;There is a Data Validation transformation that covers some use cases.&lt;/P&gt;
&lt;P&gt;If you have validation like&amp;nbsp;if the value exists&amp;nbsp;in a look up table, the Look up transformation&amp;nbsp;can be used.&lt;/P&gt;
&lt;P&gt;I think (not sitting on a&amp;nbsp;DI Studio client right now) that these transformations&amp;nbsp;can trigger both return code and abortion.&lt;/P&gt;
&lt;P&gt;Abortion can also be handled by using Status Handling events.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2017 10:41:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/SAS-DI-Check-if-dataset-is-empty-and-abort-if-not/m-p/395461#M12028</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2017-09-13T10:41:12Z</dc:date>
    </item>
    <item>
      <title>Re: SAS DI Check if dataset is empty and abort if not</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/SAS-DI-Check-if-dataset-is-empty-and-abort-if-not/m-p/395860#M12040</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We've the validation already, and have a lookup wrote written the macro. The File Reader transformation doesn't have a Status Handling tab &amp;nbsp;which is what I was hoping so that doesn't work, unless there's another way I can put that in.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I'd like to do is have my User Written Code transformation with the Validation macro run first, have the error messages (if found) output to a temporary work table and either;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;by adding another transformation to abort if the dataset has records, or continue if not&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;or adding some code into pre-code of the file reader to check that dataset, and abort if it has records, or continue if not&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;or any other method I can do this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;From what I can see, the Return Code transformation doesn't give me a chance to continue if failed, and not sure how I can status handling before or on the file reader step.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Sep 2017 07:44:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/SAS-DI-Check-if-dataset-is-empty-and-abort-if-not/m-p/395860#M12040</guid>
      <dc:creator>titan31</dc:creator>
      <dc:date>2017-09-14T07:44:55Z</dc:date>
    </item>
    <item>
      <title>Re: SAS DI Check if dataset is empty and abort if not</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/SAS-DI-Check-if-dataset-is-empty-and-abort-if-not/m-p/395887#M12041</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/130025"&gt;@titan31&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;What you describe sounds to me already like a bit too much user written code (like this macro you mention). But not knowing the details below some SAS code which you could run after the error table gets created, either as post code or as a separate user written node.&lt;/P&gt;
&lt;P&gt;If there is a macro for capturing errors but you then only keep those error in a work table and you are not really interested to look at these error records then why don't you just abort the job directly in this macro as soon as it finds the first error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But o.k., here a code sample that aborts the job if&amp;nbsp;table &lt;EM&gt;test&lt;/EM&gt; got any rows.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  if nobs&amp;gt;0 then
    do;
      put 'Table Test has ' nobs 'rows';
      put 'Aborting job';
      abort abend;
    end;
  stop;
  set test nobs=nobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 14 Sep 2017 12:15:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/SAS-DI-Check-if-dataset-is-empty-and-abort-if-not/m-p/395887#M12041</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-09-14T12:15:48Z</dc:date>
    </item>
    <item>
      <title>Re: SAS DI Check if dataset is empty and abort if not</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/SAS-DI-Check-if-dataset-is-empty-and-abort-if-not/m-p/395992#M12043</link>
      <description>Hi, Thanks for that. Will try that now. We need to get all the errors as we'll send it back to business with all the errors and the line numbers of the file if there are any issues. But, we don't want to continue the job as if there are issues, we don't want to upload bad data into VA</description>
      <pubDate>Thu, 14 Sep 2017 15:53:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/SAS-DI-Check-if-dataset-is-empty-and-abort-if-not/m-p/395992#M12043</guid>
      <dc:creator>titan31</dc:creator>
      <dc:date>2017-09-14T15:53:33Z</dc:date>
    </item>
    <item>
      <title>Re: SAS DI Check if dataset is empty and abort if not</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/SAS-DI-Check-if-dataset-is-empty-and-abort-if-not/m-p/397090#M12054</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/130025"&gt;@titan31&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;With DIS you normally would use a Validation node which allows you to implement validation rules which populates Error and Exception tables. You wouldn't use a custom writte SAS macro for such a task if you can do it differently.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Sep 2017 12:11:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/SAS-DI-Check-if-dataset-is-empty-and-abort-if-not/m-p/397090#M12054</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-09-19T12:11:56Z</dc:date>
    </item>
  </channel>
</rss>

