<?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 Macro execution in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-execution/m-p/227388#M40966</link>
    <description>&lt;P&gt;I've trouble understanding the macro execution. When I tried to run the code below, .csv file got generated where as it could not be as log.error_table has 0 observations.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm execpting this code to produce error_table.csv only if log.error_table not equal to zero observations. Could someone guide me to achive this task?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro export_conditionally;
 

proc sql noprint;
select count(*)  into :count from log.error_table;
quit;


 
%if "&amp;amp;count" ne 0 %then %do;
   proc export data=log.error_table outfile='/usr/sas/tir/work/error_table.csv' dbms=csv replace;
run;

%end;
 
%mend;

%export_conditionally;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Log:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
18        +
  select   
19        + count(*)  into :count from log.error_table;
19        +                                              quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

19        +                                                        proc export data=log.error_table 
outfile='/usr/sas/tir/work/error_table.csv' dbms=csv replace;
19        +
&amp;#12;17                                                         The SAS System                         07:03 Saturday, September 26, 2015

  run;     

NOTE: No observations in data set LOG.ERROR_TABLE.
NOTE: Data set has 0 observations.&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 26 Sep 2015 11:23:57 GMT</pubDate>
    <dc:creator>Babloo</dc:creator>
    <dc:date>2015-09-26T11:23:57Z</dc:date>
    <item>
      <title>Macro execution</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-execution/m-p/227388#M40966</link>
      <description>&lt;P&gt;I've trouble understanding the macro execution. When I tried to run the code below, .csv file got generated where as it could not be as log.error_table has 0 observations.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm execpting this code to produce error_table.csv only if log.error_table not equal to zero observations. Could someone guide me to achive this task?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro export_conditionally;
 

proc sql noprint;
select count(*)  into :count from log.error_table;
quit;


 
%if "&amp;amp;count" ne 0 %then %do;
   proc export data=log.error_table outfile='/usr/sas/tir/work/error_table.csv' dbms=csv replace;
run;

%end;
 
%mend;

%export_conditionally;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Log:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
18        +
  select   
19        + count(*)  into :count from log.error_table;
19        +                                              quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

19        +                                                        proc export data=log.error_table 
outfile='/usr/sas/tir/work/error_table.csv' dbms=csv replace;
19        +
&amp;#12;17                                                         The SAS System                         07:03 Saturday, September 26, 2015

  run;     

NOTE: No observations in data set LOG.ERROR_TABLE.
NOTE: Data set has 0 observations.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 26 Sep 2015 11:23:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-execution/m-p/227388#M40966</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2015-09-26T11:23:57Z</dc:date>
    </item>
    <item>
      <title>Re: Macro execution</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-execution/m-p/227392#M40969</link>
      <description>1. check what happens to the macro variable if the table does not exist&lt;BR /&gt;2. Check your comparison "&amp;amp;count" = 0, I don't think you need the quotes.</description>
      <pubDate>Sat, 26 Sep 2015 15:51:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-execution/m-p/227392#M40969</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-09-26T15:51:25Z</dc:date>
    </item>
    <item>
      <title>Re: Macro execution</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-execution/m-p/227406#M40974</link>
      <description>&lt;P&gt;Agree with Reeza. &amp;nbsp;If you turn on options mlogic, you should see that&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%if "&amp;amp;count" ne 0 %then %do;&lt;/PRE&gt;&lt;P&gt;evalutes to true (not equal) even when &amp;amp;count=0. &amp;nbsp; The above comparison will compare the three character string "0" to the one character string 0, and return true (not equal). &amp;nbsp;Because all macro variables resolve to text, you do not need quote marks around text strings. &amp;nbsp;Suggest you change to:&lt;/P&gt;&lt;PRE&gt;%if &amp;amp;count ne 0 %then %do;&lt;/PRE&gt;</description>
      <pubDate>Sat, 26 Sep 2015 20:52:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-execution/m-p/227406#M40974</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2015-09-26T20:52:58Z</dc:date>
    </item>
  </channel>
</rss>

