<?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 Help on SAS macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Help-on-SAS-macro/m-p/202495#M37779</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I wanted to create the sales report for 1000 merchants that too it should run in the batch mode. So i am using macro facilties to avoid the coding work. But the problem some datasets does not have any observations so it is unable to create any intermidiate tables. getting error message the file table_merchant_77 does not exit and it is passing error code = 8 so my jobs will be failed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please can you let me know how to avoid the macro exution if dataset is having zero observations.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please consider the code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;option nosyntaxcheck &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;Data &lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;merchant_1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;Input I&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;tem $ sales_amount;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;Datalines&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background: #ffffc0; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;shoe 50&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background: #ffffc0; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;fan&amp;nbsp; 100&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background: #ffffc0; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;TV&amp;nbsp;&amp;nbsp; 500&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background: #ffffc0; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;SOFA 1000&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;Data &lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;merchant_999;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;Input &lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;item $ sales_amount;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;Datalines&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background: #ffffc0; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;LOCK 50&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background: #ffffc0; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;PC&amp;nbsp;&amp;nbsp; 100&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background: #ffffc0; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;MUG&amp;nbsp;&amp;nbsp; 500&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background: #ffffc0; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;LAPTOP 1000&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;%macro &lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;report(seq);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN style="color: black; font-family: 'Courier New'; font-size: 12pt;"&gt;ODS OUTPUT TABLE=TABLE_&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;merchant_&amp;amp;seq&lt;/SPAN&gt;&lt;SPAN style="color: black; font-family: 'Courier New'; font-size: 12pt;"&gt; (DROP=_TABLE_ _PAGE_);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN style="color: black; font-family: 'Courier New'; font-size: 12pt;"&gt;PROC TABULATE DATA=&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;merchant_&amp;amp;seq&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="color: black; font-family: 'Courier New'; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CLASS ****;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="color: black; font-family: 'Courier New'; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TABLE ****;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN style="color: black; font-family: 'Courier New'; font-size: 12pt;"&gt;RUN;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN style="color: black; font-family: 'Courier New'; font-size: 12pt;"&gt;ODS LISTING;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN style="color: black; font-family: 'Courier New'; font-size: 12pt;"&gt;ODS OUTPUT&lt;BR /&gt;CLOSE;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;%mend r&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;eport&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;%&lt;STRONG&gt;&lt;EM&gt;report&lt;/EM&gt;&lt;/STRONG&gt;(&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;%&lt;STRONG&gt;&lt;EM&gt;report&lt;/EM&gt;&lt;/STRONG&gt;(&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;2&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;%&lt;STRONG&gt;&lt;EM&gt;report&lt;/EM&gt;&lt;/STRONG&gt;(&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;3&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;%&lt;STRONG&gt;&lt;EM&gt;report&lt;/EM&gt;&lt;/STRONG&gt;(&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;4&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;%&lt;STRONG&gt;&lt;EM&gt;report&lt;/EM&gt;&lt;/STRONG&gt;(&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;5&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;%&lt;STRONG&gt;&lt;EM&gt;report&lt;/EM&gt;&lt;/STRONG&gt;(&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;6&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;%&lt;STRONG&gt;&lt;EM&gt;report&lt;/EM&gt;&lt;/STRONG&gt;(&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;7&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;%&lt;STRONG&gt;&lt;EM&gt;report&lt;/EM&gt;&lt;/STRONG&gt;(&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;8&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt; .&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;%&lt;STRONG&gt;&lt;EM&gt;report&lt;/EM&gt;&lt;/STRONG&gt;(999&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 14 Jul 2015 17:36:11 GMT</pubDate>
    <dc:creator>KannanBaskar</dc:creator>
    <dc:date>2015-07-14T17:36:11Z</dc:date>
    <item>
      <title>Help on SAS macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-on-SAS-macro/m-p/202495#M37779</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I wanted to create the sales report for 1000 merchants that too it should run in the batch mode. So i am using macro facilties to avoid the coding work. But the problem some datasets does not have any observations so it is unable to create any intermidiate tables. getting error message the file table_merchant_77 does not exit and it is passing error code = 8 so my jobs will be failed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please can you let me know how to avoid the macro exution if dataset is having zero observations.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please consider the code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;option nosyntaxcheck &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;Data &lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;merchant_1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;Input I&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;tem $ sales_amount;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;Datalines&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background: #ffffc0; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;shoe 50&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background: #ffffc0; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;fan&amp;nbsp; 100&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background: #ffffc0; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;TV&amp;nbsp;&amp;nbsp; 500&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background: #ffffc0; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;SOFA 1000&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;Data &lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;merchant_999;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;Input &lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;item $ sales_amount;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;Datalines&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background: #ffffc0; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;LOCK 50&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background: #ffffc0; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;PC&amp;nbsp;&amp;nbsp; 100&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background: #ffffc0; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;MUG&amp;nbsp;&amp;nbsp; 500&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background: #ffffc0; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;LAPTOP 1000&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;%macro &lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;report(seq);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN style="color: black; font-family: 'Courier New'; font-size: 12pt;"&gt;ODS OUTPUT TABLE=TABLE_&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;merchant_&amp;amp;seq&lt;/SPAN&gt;&lt;SPAN style="color: black; font-family: 'Courier New'; font-size: 12pt;"&gt; (DROP=_TABLE_ _PAGE_);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN style="color: black; font-family: 'Courier New'; font-size: 12pt;"&gt;PROC TABULATE DATA=&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;merchant_&amp;amp;seq&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="color: black; font-family: 'Courier New'; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CLASS ****;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="color: black; font-family: 'Courier New'; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TABLE ****;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN style="color: black; font-family: 'Courier New'; font-size: 12pt;"&gt;RUN;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN style="color: black; font-family: 'Courier New'; font-size: 12pt;"&gt;ODS LISTING;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN style="color: black; font-family: 'Courier New'; font-size: 12pt;"&gt;ODS OUTPUT&lt;BR /&gt;CLOSE;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;%mend r&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;eport&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;%&lt;STRONG&gt;&lt;EM&gt;report&lt;/EM&gt;&lt;/STRONG&gt;(&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;%&lt;STRONG&gt;&lt;EM&gt;report&lt;/EM&gt;&lt;/STRONG&gt;(&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;2&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;%&lt;STRONG&gt;&lt;EM&gt;report&lt;/EM&gt;&lt;/STRONG&gt;(&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;3&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;%&lt;STRONG&gt;&lt;EM&gt;report&lt;/EM&gt;&lt;/STRONG&gt;(&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;4&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;%&lt;STRONG&gt;&lt;EM&gt;report&lt;/EM&gt;&lt;/STRONG&gt;(&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;5&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;%&lt;STRONG&gt;&lt;EM&gt;report&lt;/EM&gt;&lt;/STRONG&gt;(&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;6&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;%&lt;STRONG&gt;&lt;EM&gt;report&lt;/EM&gt;&lt;/STRONG&gt;(&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;7&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;%&lt;STRONG&gt;&lt;EM&gt;report&lt;/EM&gt;&lt;/STRONG&gt;(&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;8&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt; .&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;%&lt;STRONG&gt;&lt;EM&gt;report&lt;/EM&gt;&lt;/STRONG&gt;(999&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Jul 2015 17:36:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-on-SAS-macro/m-p/202495#M37779</guid>
      <dc:creator>KannanBaskar</dc:creator>
      <dc:date>2015-07-14T17:36:11Z</dc:date>
    </item>
    <item>
      <title>Re: Help on SAS macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-on-SAS-macro/m-p/202496#M37780</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can add an observation check on the data set before you run the proc tabulate and do nothing if it's empty.&amp;nbsp; Try adding the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro report(seq);&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;%let DSID=%sysfunc(OPEN(merchant_&amp;amp;seq.,IN));&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;%let NOBS=%sysfunc(ATTRN(&amp;amp;DSID,NOBS));&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;%let RC=%sysfunc(CLOSE(merchant_&amp;amp;seq));&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;%IF &amp;amp;NOBS=0 %THEN %DO:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %PUT "NO OBSERVATIONS IN MERCHANT_&amp;amp;SEQ DATA SET";&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/STRONG&gt;&lt;STRONG&gt;%END;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;%ELSE %DO;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;ODS OUTPUT TABLE=TABLE_merchange_&amp;amp;seq (DROP=_TABLE_ _PAGE_);&lt;/P&gt;&lt;P&gt;PROC TABULATE DATA=merchant_&amp;amp;seq&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CLASS ****;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TABLE ****;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;ODS LISTING;&lt;/P&gt;&lt;P&gt;ODS OUTPUT CLOSE;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;%END;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope that helps!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Jul 2015 18:41:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-on-SAS-macro/m-p/202496#M37780</guid>
      <dc:creator>dcruik</dc:creator>
      <dc:date>2015-07-14T18:41:00Z</dc:date>
    </item>
    <item>
      <title>Re: Help on SAS macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-on-SAS-macro/m-p/202497#M37781</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Hi Kannan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One way is to have another macro test if a data set exists, and if so, then count the number of observations.&lt;/P&gt;&lt;P&gt;Then, if the conditions are met, call the macro that does the PROC.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've taken your data and simplified it a bit (using PROC MEANS, and creating a 0 obs data set)....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data merchant_1;&lt;BR /&gt;&amp;nbsp; Input Item $ sales_amount;&lt;BR /&gt;&amp;nbsp; Datalines;&lt;BR /&gt;&amp;nbsp; shoe 50&lt;BR /&gt;&amp;nbsp; fan&amp;nbsp; 100&lt;BR /&gt;&amp;nbsp; TV&amp;nbsp;&amp;nbsp; 500&lt;BR /&gt;&amp;nbsp; SOFA 1000&lt;BR /&gt;&amp;nbsp; ;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Data merchant_999;&lt;BR /&gt;&amp;nbsp; Input item $ sales_amount;&lt;BR /&gt;&amp;nbsp; Datalines;&lt;BR /&gt;&amp;nbsp; LOCK 50&lt;BR /&gt;&amp;nbsp; PC&amp;nbsp;&amp;nbsp; 100&lt;BR /&gt;&amp;nbsp; MUG&amp;nbsp;&amp;nbsp; 500&lt;BR /&gt;&amp;nbsp; LAPTOP 1000&lt;BR /&gt;&amp;nbsp; ;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;/* create data set with 0 obs...*/&lt;BR /&gt;data MERCHANT_2;&amp;nbsp; &lt;BR /&gt;set MERCHANT_1;&lt;BR /&gt;if sales_amount &amp;lt; 1;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%macro TAB;&lt;BR /&gt;proc means data=MERCHANT_&amp;amp;seq ;&lt;BR /&gt;var sales_amount;&lt;BR /&gt;title1 "STATISTICS from data set MERCHANT_&amp;amp;seq";&lt;BR /&gt;run;&lt;BR /&gt;%mend TAB;&lt;/P&gt;&lt;P&gt;%macro REPORT(seq);&lt;BR /&gt;%if %sysfunc(exist(MERCHANT_&amp;amp;seq)) %then %do;&lt;BR /&gt; %let dsid = %sysfunc(open(MERCHANT_&amp;amp;seq));&amp;nbsp; *open the data set ;&lt;BR /&gt; %let NumObs = %sysfunc(attrn(&amp;amp;dsid,nlobs)); *count number of logical observations ;&lt;BR /&gt; %let RC = %sysfunc(close(&amp;amp;Dsid));&lt;BR /&gt;&amp;nbsp; %IF &amp;amp;NUMOBS &amp;gt; 0 %then &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %TAB;&lt;BR /&gt;&amp;nbsp; %ELSE &lt;BR /&gt;&amp;nbsp;&amp;nbsp; %PUT "DATA SET MERCHANT_&amp;amp;seq HAS 0 OBS!!";&lt;BR /&gt;%end;&lt;BR /&gt;%ELSE&lt;BR /&gt; %put "DATA SET MERCHANT_&amp;amp;seq DOES NOT EXIST!!";&lt;BR /&gt;%mend REPORT;&lt;/P&gt;&lt;P&gt;%report(1)&lt;BR /&gt;%report(2)&lt;BR /&gt;%report(3)&lt;BR /&gt;%report(999)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Jul 2015 19:18:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-on-SAS-macro/m-p/202497#M37781</guid>
      <dc:creator>Tommywhosc</dc:creator>
      <dc:date>2015-07-14T19:18:22Z</dc:date>
    </item>
  </channel>
</rss>

