<?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: How to use macro only if condition is met in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-macro-only-if-condition-is-met/m-p/781954#M249247</link>
    <description>&lt;P&gt;Here you go:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _NULL_;
 if 0 then set WORK.TEST nobs=n;
 put "no. of observations =" n;
 if n^=0 then call execute("%nrstr(%send_email(&amp;amp;emails_to., &amp;amp;subject.);)");
 stop;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 23 Nov 2021 14:05:11 GMT</pubDate>
    <dc:creator>Oligolas</dc:creator>
    <dc:date>2021-11-23T14:05:11Z</dc:date>
    <item>
      <title>How to use macro only if condition is met</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-macro-only-if-condition-is-met/m-p/781942#M249243</link>
      <description>&lt;P&gt;Hi.&lt;BR /&gt;I don't use a macro in SAS very often. There is one that I use to send e-mails. However, I don't want this macro to be used every time. I want to add a condition that if the WORK.TEST table is empty (no rows) then do not execute the macro, otherwise it will execute the macro.&lt;/P&gt;
&lt;P&gt;Macro code is here:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro send_email(to, subject);
FILENAME Mailbox EMAIL;
	data _NULL_;
		file MailBox 
		to=(&amp;amp;to.)
		from='noreply@***.com'
		subject=&amp;amp;subject.;
		put "This is email sent by macro.";
	run;
%mend;
%let today_d = %sysfunc(date(), DDMMYY10.);
%let emails_to = "myemail@***.com";
%let subject = "Subject of mail and date: &amp;amp;today_d.";
%send_email(&amp;amp;emails_to., &amp;amp;subject.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Can You help me with solution how to execute macro if work.test is not empty?&lt;/P&gt;</description>
      <pubDate>Tue, 23 Nov 2021 13:32:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-macro-only-if-condition-is-met/m-p/781942#M249243</guid>
      <dc:creator>PatrykSAS</dc:creator>
      <dc:date>2021-11-23T13:32:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to use macro only if condition is met</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-macro-only-if-condition-is-met/m-p/781954#M249247</link>
      <description>&lt;P&gt;Here you go:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _NULL_;
 if 0 then set WORK.TEST nobs=n;
 put "no. of observations =" n;
 if n^=0 then call execute("%nrstr(%send_email(&amp;amp;emails_to., &amp;amp;subject.);)");
 stop;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 23 Nov 2021 14:05:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-macro-only-if-condition-is-met/m-p/781954#M249247</guid>
      <dc:creator>Oligolas</dc:creator>
      <dc:date>2021-11-23T14:05:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to use macro only if condition is met</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-macro-only-if-condition-is-met/m-p/782040#M249286</link>
      <description>&lt;P&gt;You can take advantage of the fact that SAS will end a data step when you read past the end of the data to simplify that step.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _NULL_;
  put "no. of observations =" n;
  set WORK.TEST nobs=n;
  call execute("%nrstr(%send_email(&amp;amp;emails_to., &amp;amp;subject.);)");
  stop;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 23 Nov 2021 18:21:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-macro-only-if-condition-is-met/m-p/782040#M249286</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-11-23T18:21:50Z</dc:date>
    </item>
  </channel>
</rss>

