<?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: Conditional Logic; If previous data set is empty, do A, else do B in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Conditional-Logic-If-previous-data-set-is-empty-do-A-else-do-B/m-p/251548#M17751</link>
    <description>&lt;P&gt;If you know the name of the dataset in question, you can do something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro check_if_null(dataset);

data _null_;
if done and _n_ = 1 then call symput('errorcheck','no');
if _n_ = 2 then do; call symput('errorcheck','yes'); stop; end;
set &amp;amp;dataset end=done;
run;

%put errorcheck=&amp;amp;errorcheck;

%mend;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Instead of the %put, you can insert your code for sending emails.&lt;/P&gt;</description>
    <pubDate>Mon, 22 Feb 2016 14:51:04 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2016-02-22T14:51:04Z</dc:date>
    <item>
      <title>Conditional Logic; If previous data set is empty, do A, else do B</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Conditional-Logic-If-previous-data-set-is-empty-do-A-else-do-B/m-p/251544#M17749</link>
      <description>&lt;P&gt;I have a data integrity query that if everything is running smoothly, when the query is done, ideally there should be no results.&lt;/P&gt;&lt;P&gt;I want to have a conditional step after that query that send out one of two emails. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. &amp;nbsp;If the previous query is null; send out an email saying, great job, no errors.&lt;/P&gt;&lt;P&gt;2. &amp;nbsp;If the previous query is not null; sent out an email saying; please see corrections and attach the file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there an easy way to do this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let me state, I *only* use the visual interface for Enterprise Guide. &amp;nbsp;I have zero knowledge of the SAS language or how to integrate SAS programming into my visual EG use. &amp;nbsp;The answer to my question might be there is no easy way.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The only way I've been able to do it so far is very convoluted. &amp;nbsp;I take my query and append a dummy result, sort it and in the conditional step say if the first results equals my appended data, then then the null email. &amp;nbsp;Else, I have to filter out my appended result so as to not send dummy data, then send out the attached result email. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 22 Feb 2016 14:53:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Conditional-Logic-If-previous-data-set-is-empty-do-A-else-do-B/m-p/251544#M17749</guid>
      <dc:creator>mfeller</dc:creator>
      <dc:date>2016-02-22T14:53:46Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Logic; If previous data set is empty, do A, else do B</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Conditional-Logic-If-previous-data-set-is-empty-do-A-else-do-B/m-p/251547#M17750</link>
      <description>&lt;P&gt;Well, it depends, your on EG so its a bit different to my SAS. &amp;nbsp;What is created by the previous step? &amp;nbsp;If there are no errors, does it create a dataset with zero observations, or no dataset at all? &amp;nbsp;If it is zero observations then something like:&lt;/P&gt;
&lt;PRE&gt;data _null_;
  set sashelp.vtable (where=(libname="&amp;lt;your_libname" and memname="&amp;lt;your_dataset&amp;gt;" and nobs ne 0));
  call execute('filename mymail email ....;');
run;&lt;/PRE&gt;
&lt;P&gt;I.e. the call execute will only run if there are any observations with the where clause, i.e. if you have that dataset and it has observations.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If it doesn't create a dataset at all then you may want to look at exists function:&lt;/P&gt;
&lt;PRE&gt;data _null_;
  if exists(&amp;lt;your_libname&amp;gt;.&amp;lt;your_dataset&amp;gt;) then call execute('filename mymail email ....;');
run;&lt;/PRE&gt;</description>
      <pubDate>Mon, 22 Feb 2016 14:50:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Conditional-Logic-If-previous-data-set-is-empty-do-A-else-do-B/m-p/251547#M17750</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-02-22T14:50:38Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Logic; If previous data set is empty, do A, else do B</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Conditional-Logic-If-previous-data-set-is-empty-do-A-else-do-B/m-p/251548#M17751</link>
      <description>&lt;P&gt;If you know the name of the dataset in question, you can do something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro check_if_null(dataset);

data _null_;
if done and _n_ = 1 then call symput('errorcheck','no');
if _n_ = 2 then do; call symput('errorcheck','yes'); stop; end;
set &amp;amp;dataset end=done;
run;

%put errorcheck=&amp;amp;errorcheck;

%mend;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Instead of the %put, you can insert your code for sending emails.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Feb 2016 14:51:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Conditional-Logic-If-previous-data-set-is-empty-do-A-else-do-B/m-p/251548#M17751</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-02-22T14:51:04Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Logic; If previous data set is empty, do A, else do B</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Conditional-Logic-If-previous-data-set-is-empty-do-A-else-do-B/m-p/251552#M17752</link>
      <description>&lt;P&gt;I edited my post to state that I'm trying to do this solely in the EG visual tool, as I don't know any SAS programming.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 22 Feb 2016 14:54:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Conditional-Logic-If-previous-data-set-is-empty-do-A-else-do-B/m-p/251552#M17752</guid>
      <dc:creator>mfeller</dc:creator>
      <dc:date>2016-02-22T14:54:58Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Logic; If previous data set is empty, do A, else do B</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Conditional-Logic-If-previous-data-set-is-empty-do-A-else-do-B/m-p/251554#M17753</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/57168"&gt;@mfeller&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;as I don't know any SAS programming.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Then it's high time you start learning it. All advanced problem solving in SAS requires programming skills.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Feb 2016 14:57:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Conditional-Logic-If-previous-data-set-is-empty-do-A-else-do-B/m-p/251554#M17753</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-02-22T14:57:26Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Logic; If previous data set is empty, do A, else do B</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Conditional-Logic-If-previous-data-set-is-empty-do-A-else-do-B/m-p/251555#M17754</link>
      <description>&lt;P&gt;Wow, thank you for that completely unhelpful reply. &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Feb 2016 14:58:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Conditional-Logic-If-previous-data-set-is-empty-do-A-else-do-B/m-p/251555#M17754</guid>
      <dc:creator>mfeller</dc:creator>
      <dc:date>2016-02-22T14:58:19Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Logic; If previous data set is empty, do A, else do B</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Conditional-Logic-If-previous-data-set-is-empty-do-A-else-do-B/m-p/251557#M17755</link>
      <description>&lt;P&gt;Don't be too hard on Kurt. When you've used SAS for a long time, you become a very fervent advocate!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, it is possible to meet your needs using only EG. Here's how:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. I'm assuming you know how to set up your steps to send out the emails.&lt;/P&gt;&lt;P&gt;2. Use the query builder on the result dataset of your query; drag any column into the "select data" grid, and set the Summary option to "Count".&lt;/P&gt;&lt;P&gt;3. When you run the query, you'll get a single observation with a single variable which will be the count of non-null values in the column. If everything went well, I assume this will be zero, otherwise it will be non-zero.&lt;/P&gt;&lt;P&gt;4. You can now hang your dependent email tasks off of this query result, and set a condition to execute them based on whether the value of the contents is zero or not.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Tom&lt;/P&gt;</description>
      <pubDate>Mon, 22 Feb 2016 15:11:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Conditional-Logic-If-previous-data-set-is-empty-do-A-else-do-B/m-p/251557#M17755</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2016-02-22T15:11:04Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Logic; If previous data set is empty, do A, else do B</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Conditional-Logic-If-previous-data-set-is-empty-do-A-else-do-B/m-p/251563#M17757</link>
      <description>&lt;P&gt;This response is perfect. &amp;nbsp;I'm going to clean up my queries that have conditional logic now. &amp;nbsp;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;P.S. &amp;nbsp;As for Kurt, this was my first post ever to this forum. &amp;nbsp;Telling me to learn SAS programming is not helpful at all to my current predicament. &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Feb 2016 15:36:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Conditional-Logic-If-previous-data-set-is-empty-do-A-else-do-B/m-p/251563#M17757</guid>
      <dc:creator>mfeller</dc:creator>
      <dc:date>2016-02-22T15:36:12Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Logic; If previous data set is empty, do A, else do B</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Conditional-Logic-If-previous-data-set-is-empty-do-A-else-do-B/m-p/251564#M17758</link>
      <description>&lt;P&gt;When you ask for help, you get what you get. Someday you may want his help so no point being rude either.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Feb 2016 15:45:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Conditional-Logic-If-previous-data-set-is-empty-do-A-else-do-B/m-p/251564#M17758</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-02-22T15:45:25Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Logic; If previous data set is empty, do A, else do B</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Conditional-Logic-If-previous-data-set-is-empty-do-A-else-do-B/m-p/251566#M17759</link>
      <description>&lt;P&gt;I asked for an apple, and was told I don't want to eat an apple, I should want a pomegranate.&lt;/P&gt;&lt;P&gt;I think responses like that should be discouraged as it's not helpful for anyone in the community. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Feb 2016 15:52:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Conditional-Logic-If-previous-data-set-is-empty-do-A-else-do-B/m-p/251566#M17759</guid>
      <dc:creator>mfeller</dc:creator>
      <dc:date>2016-02-22T15:52:19Z</dc:date>
    </item>
  </channel>
</rss>

