<?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 Export data only when the data is not empty in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Export-data-only-when-the-data-is-not-empty/m-p/39783#M4769</link>
    <description>Hi i have a code which export many datasets out. However, some of the datasets can be empty sometimes. Is there any command which i can use to export only non-empty data?</description>
    <pubDate>Mon, 18 Aug 2008 06:58:23 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2008-08-18T06:58:23Z</dc:date>
    <item>
      <title>Export data only when the data is not empty</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Export-data-only-when-the-data-is-not-empty/m-p/39783#M4769</link>
      <description>Hi i have a code which export many datasets out. However, some of the datasets can be empty sometimes. Is there any command which i can use to export only non-empty data?</description>
      <pubDate>Mon, 18 Aug 2008 06:58:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Export-data-only-when-the-data-is-not-empty/m-p/39783#M4769</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-08-18T06:58:23Z</dc:date>
    </item>
    <item>
      <title>Re: Export data only when the data is not empty</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Export-data-only-when-the-data-is-not-empty/m-p/39784#M4770</link>
      <description>I don't know the neatest way in EG to do this, but you can use either DICTIONARY.TABLES or the ATTRN function to find out whether your input table(s) has observations or not, and combine this with some conditional logic using macro programming.&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
Linus</description>
      <pubDate>Mon, 18 Aug 2008 11:07:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Export-data-only-when-the-data-is-not-empty/m-p/39784#M4770</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2008-08-18T11:07:49Z</dc:date>
    </item>
    <item>
      <title>Re: Export data only when the data is not empty</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Export-data-only-when-the-data-is-not-empty/m-p/39785#M4771</link>
      <description>use open() and attrn function, you can get the attribution of the table such as variable number , if it is a empty table, the variable number should be 0</description>
      <pubDate>Tue, 19 Aug 2008 02:35:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Export-data-only-when-the-data-is-not-empty/m-p/39785#M4771</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-08-19T02:35:13Z</dc:date>
    </item>
    <item>
      <title>Re: Export data only when the data is not empty</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Export-data-only-when-the-data-is-not-empty/m-p/39786#M4772</link>
      <description>&amp;gt; use open() and attrn function, you can get the&lt;BR /&gt;
&amp;gt; attribution of the table such as variable number , if&lt;BR /&gt;
&amp;gt; it is a empty table, the variable number should be 0&lt;BR /&gt;
&lt;BR /&gt;
The number of variables is not reduced to 0 if a dataset is empty, to find out how many observations are in a dataset use NOBS as second parameter for the attrn function.</description>
      <pubDate>Thu, 21 Aug 2008 06:13:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Export-data-only-when-the-data-is-not-empty/m-p/39786#M4772</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2008-08-21T06:13:03Z</dc:date>
    </item>
    <item>
      <title>Re: Export data only when the data is not empty</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Export-data-only-when-the-data-is-not-empty/m-p/39787#M4773</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
Thanks so much everyone, I manage to find out the number of observation using the attrn function. However, does anybody knows how to link the following 2 codes together such that it only export data testing if it is non-empty? I tried '%if... then..." but it returns with error message.&lt;BR /&gt;
&lt;BR /&gt;
1) %let dsid=%sysfunc(open(testing,i));&lt;BR /&gt;
  %let iswhere=%sysfunc(attrn(&amp;amp;dsid,nobs));&lt;BR /&gt;
&lt;BR /&gt;
2) proc export data=testing&lt;BR /&gt;
   OUTFILE="/SAS/SGH/PFS_CCR/Collection/Risk12/testing&amp;amp;d5.xls"&lt;BR /&gt;
   DBMS=xls REPLACE;&lt;BR /&gt;
   RUN;</description>
      <pubDate>Thu, 21 Aug 2008 11:09:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Export-data-only-when-the-data-is-not-empty/m-p/39787#M4773</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-08-21T11:09:00Z</dc:date>
    </item>
    <item>
      <title>Re: Export data only when the data is not empty</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Export-data-only-when-the-data-is-not-empty/m-p/39788#M4774</link>
      <description>Somthing like this (untested):&lt;BR /&gt;
&lt;BR /&gt;
%macro export(table);&lt;BR /&gt;
%let dsid=%sysfunc(open(testing,i));&lt;BR /&gt;
%let iswhere=%sysfunc(attrn(&amp;amp;dsid,nobs));&lt;BR /&gt;
%if &amp;amp;ISWHERE ne 0 %the %do;&lt;BR /&gt;
 proc export data=&amp;amp;TABLE&lt;BR /&gt;
OUTFILE="/SAS/SGH/PFS_CCR/Collection/Risk12/testing&amp;amp;d5.xls"&lt;BR /&gt;
DBMS=xls REPLACE;&lt;BR /&gt;
RUN; &lt;BR /&gt;
%end;&lt;BR /&gt;
%mend export;&lt;BR /&gt;
%export;&lt;BR /&gt;
&lt;BR /&gt;
/Linus</description>
      <pubDate>Thu, 21 Aug 2008 13:05:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Export-data-only-when-the-data-is-not-empty/m-p/39788#M4774</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2008-08-21T13:05:52Z</dc:date>
    </item>
  </channel>
</rss>

