<?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: Generate an empty file using proc export in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Generate-an-empty-file-using-proc-export/m-p/598336#M172550</link>
    <description>&lt;P&gt;Perhaps this would help:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://github.com/scottbass/SAS/blob/master/Macro/export.sas" target="_blank"&gt;https://github.com/scottbass/SAS/blob/master/Macro/export.sas&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Stolen from:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-use-labels-in-proc-export-or-create-tab-dlm-file-using/m-p/76789#M8698" target="_self"&gt;&lt;SPAN&gt;https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-use-labels-in-proc-export-or-create-tab-dlm-file-using/m-p/76789#M8698&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 22 Oct 2019 07:32:56 GMT</pubDate>
    <dc:creator>ScottBass</dc:creator>
    <dc:date>2019-10-22T07:32:56Z</dc:date>
    <item>
      <title>Generate an empty file using proc export</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Generate-an-empty-file-using-proc-export/m-p/598296#M172536</link>
      <description>&lt;P&gt;Hi experts,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using "proc export" to generate a file with the option putnames=no, when the file has at least one record i don´t have any problem, but when the file is empty, the files is generated (0 bytes, just the name), but the sas program returns me this message&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;NOTE: 0 records were written to the file '/sasdatos/xxxxx/crea.txt'.&lt;BR /&gt;NOTE: There were 0 observations read from the data set WORK.PRUEBA.&lt;BR /&gt;NOTE: Sentencia DATA used (Total process time):&lt;BR /&gt;real time 0.00 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;/P&gt;&lt;P&gt;0 records created in /sasdatos/xxxxx/crea.txt from WORK.PRUEBA.&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;&lt;U&gt;ERROR: Export unsuccessful. See SAS Log for details.&lt;/U&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;NOTE: PROCEDIMIENTO EXPORT used (Total process time):&lt;BR /&gt;real time 0.05 seconds&lt;BR /&gt;cpu time 0.06 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The program stops, and it doesn´t continue, can any one help me to work around this ?&amp;nbsp; Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 22 Oct 2019 01:10:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Generate-an-empty-file-using-proc-export/m-p/598296#M172536</guid>
      <dc:creator>Jose6</dc:creator>
      <dc:date>2019-10-22T01:10:28Z</dc:date>
    </item>
    <item>
      <title>Re: Generate an empty file using proc export</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Generate-an-empty-file-using-proc-export/m-p/598298#M172537</link>
      <description>&lt;P&gt;Huh?&lt;/P&gt;
&lt;P&gt;If there are no lines of data and no header line then the file SHOULD be empty.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Oct 2019 02:31:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Generate-an-empty-file-using-proc-export/m-p/598298#M172537</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-10-22T02:31:03Z</dc:date>
    </item>
    <item>
      <title>Re: Generate an empty file using proc export</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Generate-an-empty-file-using-proc-export/m-p/598306#M172540</link>
      <description>The problem it is not the empty file, the problem is the error being&lt;BR /&gt;generated by this, I want to avoid the error in order to continue with the&lt;BR /&gt;other part of the program&lt;BR /&gt;</description>
      <pubDate>Tue, 22 Oct 2019 03:31:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Generate-an-empty-file-using-proc-export/m-p/598306#M172540</guid>
      <dc:creator>Jose6</dc:creator>
      <dc:date>2019-10-22T03:31:11Z</dc:date>
    </item>
    <item>
      <title>Re: Generate an empty file using proc export</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Generate-an-empty-file-using-proc-export/m-p/598323#M172547</link>
      <description>&lt;P&gt;Instead of running proc export, copy the data step from the log and run only that. As you can see in the log, the data step itself returns only NOTEs.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Oct 2019 05:54:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Generate-an-empty-file-using-proc-export/m-p/598323#M172547</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-10-22T05:54:37Z</dc:date>
    </item>
    <item>
      <title>Re: Generate an empty file using proc export</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Generate-an-empty-file-using-proc-export/m-p/598336#M172550</link>
      <description>&lt;P&gt;Perhaps this would help:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://github.com/scottbass/SAS/blob/master/Macro/export.sas" target="_blank"&gt;https://github.com/scottbass/SAS/blob/master/Macro/export.sas&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Stolen from:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-use-labels-in-proc-export-or-create-tab-dlm-file-using/m-p/76789#M8698" target="_self"&gt;&lt;SPAN&gt;https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-use-labels-in-proc-export-or-create-tab-dlm-file-using/m-p/76789#M8698&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Oct 2019 07:32:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Generate-an-empty-file-using-proc-export/m-p/598336#M172550</guid>
      <dc:creator>ScottBass</dc:creator>
      <dc:date>2019-10-22T07:32:56Z</dc:date>
    </item>
    <item>
      <title>Re: Generate an empty file using proc export</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Generate-an-empty-file-using-proc-export/m-p/598346#M172552</link>
      <description>&lt;P&gt;You could try using something like the following macro that exports a data set to a file and if the data set is empty it just creates an empty file without generating an error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* define a macro to export a data set to a file or */
/* create an empty file if the data set has 0 obs   */
%macro export_ds(dsname,fpath,fname);
   /* check how many obs are in data set */
   data _null_;
      call symputx('nobs',nobs);
      set &amp;amp;dsname(obs = 0) nobs = nobs;
   run;

   /* if there any obs in data set then export */
   %if &amp;amp;nobs %then
   %do;
      proc export
         data    = &amp;amp;dsname
         outfile = "&amp;amp;fpath/&amp;amp;fname"
         ;
      run;
   %end;
   /* otherwise create empty file */
   %else
   %do;
      data _null_;
         file "&amp;amp;fpath/&amp;amp;fname";
      run;
   %end;
%mend export_ds;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Some example calls to the macro, one with data in the data set and another with an empty data set.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;NB.&lt;/STRONG&gt; Replace "&lt;FONT face="courier new,courier"&gt;your/file/path&lt;/FONT&gt;" in the below macro calls with your actual file path.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* macro diagnostic messages in log */
options symbolgen mlogic mprint;

/* execute macro with a data set of 19 obs */
%export_ds(sashelp.class,your/file/path,tmp.txt)

/* set up a data set with 0 obs */
data have;
   set sashelp.class(obs = 0);
run;

/* execute macro with a data set of 0 obs */
%export_ds(have,your/file/path,want.txt)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;HTH.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Amir.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Oct 2019 08:56:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Generate-an-empty-file-using-proc-export/m-p/598346#M172552</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2019-10-22T08:56:22Z</dc:date>
    </item>
    <item>
      <title>Re: Generate an empty file using proc export</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Generate-an-empty-file-using-proc-export/m-p/598386#M172558</link>
      <description>&lt;P&gt;You didn't show what TYPE of file you asked PROC EXPORT to make, but since the extension is .TXT it is probably something you could make using a simple data step instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example to make a tab delimited file without a header row just do this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
   file "myfile.txt" dsd dlm='09'x ;
   set have ;
   put (_all_) (+0);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that for me PROC EXPORT does NOT generate that ERROR message.&amp;nbsp; Are you running something else that is generating that error message?&amp;nbsp; This code runs fine.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename csv temp;
proc export file=csv data=sashelp.class(obs=0) dbms=csv; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What version of SAS are you running?&amp;nbsp; See this usage note:&amp;nbsp;&amp;nbsp;&lt;A href="http://support.sas.com/kb/62/386.html" target="_blank"&gt;http://support.sas.com/kb/62/386.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Oct 2019 14:24:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Generate-an-empty-file-using-proc-export/m-p/598386#M172558</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-10-22T14:24:28Z</dc:date>
    </item>
    <item>
      <title>Re: Generate an empty file using proc export</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Generate-an-empty-file-using-proc-export/m-p/598402#M172564</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/288804"&gt;@Jose6&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi experts,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm using "proc export" to generate a file with the option putnames=no, when the file has at least one record i don´t have any problem, but when the file is empty, the files is generated (0 bytes, just the name), but the sas program returns me this message&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;NOTE: 0 records were written to the file '/sasdatos/xxxxx/crea.txt'.&lt;BR /&gt;NOTE: There were 0 observations read from the data set WORK.PRUEBA.&lt;BR /&gt;NOTE: Sentencia DATA used (Total process time):&lt;BR /&gt;real time 0.00 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;/P&gt;
&lt;P&gt;0 records created in /sasdatos/xxxxx/crea.txt from WORK.PRUEBA.&lt;BR /&gt;&lt;FONT color="#ff0000"&gt;&lt;STRONG&gt;&lt;U&gt;ERROR: Export unsuccessful. See SAS Log for details.&lt;/U&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;NOTE: PROCEDIMIENTO EXPORT used (Total process time):&lt;BR /&gt;real time 0.05 seconds&lt;BR /&gt;cpu time 0.06 seconds&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The program stops, and it doesn´t continue, can any one help me to work around this ?&amp;nbsp; Thanks!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;What do you want to happen when you request an export with nothing to export???&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One approach would be to use a data step to write the text file instead of proc export. Data steps would not generate any error. If you exporting similar files you should be able to find code to export a file in that format in the log of a successful run because Export will write the data step code to the log.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Oct 2019 14:27:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Generate-an-empty-file-using-proc-export/m-p/598402#M172564</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-10-22T14:27:49Z</dc:date>
    </item>
    <item>
      <title>Re: Generate an empty file using proc export</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Generate-an-empty-file-using-proc-export/m-p/598432#M172575</link>
      <description>&lt;P&gt;Thank you all, It was a great help!&lt;/P&gt;</description>
      <pubDate>Tue, 22 Oct 2019 15:33:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Generate-an-empty-file-using-proc-export/m-p/598432#M172575</guid>
      <dc:creator>Jose6</dc:creator>
      <dc:date>2019-10-22T15:33:39Z</dc:date>
    </item>
  </channel>
</rss>

