<?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 How to add running serial number in out file while using proc export in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-to-add-running-serial-number-in-out-file-while-using-proc/m-p/300913#M60570</link>
    <description>&lt;P&gt;Hi Team,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to generate outfile from proc eport with running serial number if file already exist with same date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;sample code to generate file name with date :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%Let fname=%sysfunc(today(),mmddyyn8.);&lt;/P&gt;
&lt;P&gt;%let file=uma;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Proc export data=work.test&lt;/P&gt;
&lt;P&gt;outfile="C:\Desktop\&amp;amp;file&amp;amp;fname.01.txt"&lt;/P&gt;
&lt;P&gt;dbms=csv;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Code would generate file : uma0927201601.txt&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am looking for that "01" in filename should get change &amp;nbsp;to 02 and 03....if i generate the same file today itself.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Uma Shanker Saini&lt;/P&gt;</description>
    <pubDate>Tue, 27 Sep 2016 02:47:23 GMT</pubDate>
    <dc:creator>umashankersaini</dc:creator>
    <dc:date>2016-09-27T02:47:23Z</dc:date>
    <item>
      <title>How to add running serial number in out file while using proc export</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-add-running-serial-number-in-out-file-while-using-proc/m-p/300913#M60570</link>
      <description>&lt;P&gt;Hi Team,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to generate outfile from proc eport with running serial number if file already exist with same date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;sample code to generate file name with date :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%Let fname=%sysfunc(today(),mmddyyn8.);&lt;/P&gt;
&lt;P&gt;%let file=uma;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Proc export data=work.test&lt;/P&gt;
&lt;P&gt;outfile="C:\Desktop\&amp;amp;file&amp;amp;fname.01.txt"&lt;/P&gt;
&lt;P&gt;dbms=csv;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Code would generate file : uma0927201601.txt&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am looking for that "01" in filename should get change &amp;nbsp;to 02 and 03....if i generate the same file today itself.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Uma Shanker Saini&lt;/P&gt;</description>
      <pubDate>Tue, 27 Sep 2016 02:47:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-add-running-serial-number-in-out-file-while-using-proc/m-p/300913#M60570</guid>
      <dc:creator>umashankersaini</dc:creator>
      <dc:date>2016-09-27T02:47:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to add running serial number in out file while using proc export</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-add-running-serial-number-in-out-file-while-using-proc/m-p/300924#M60571</link>
      <description>&lt;P&gt;This &lt;A href="https://www.researchgate.net/file.PostFileLoader.html?id=55bf26466307d9f5da8b45ae&amp;amp;assetKey=AS%3A273824220680200%401442296190128" target="_blank"&gt;document&lt;/A&gt; describes how to obtain a directory listing using only SAS functions. You can then subset on the first part of your filename, and then iterate to the last found file, add 1, and create a new filename.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Sep 2016 05:57:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-add-running-serial-number-in-out-file-while-using-proc/m-p/300924#M60571</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-09-27T05:57:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to add running serial number in out file while using proc export</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-add-running-serial-number-in-out-file-while-using-proc/m-p/300929#M60572</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
Filename Txt_List Pipe 'dir "C:\ ... \*.txt" /b'; 
Data _NULL_;
  Infile Txt_List TruncOver;
  Input Filename $100.;
  * If Find(Filename,&amp;lt;Currentdatestring&amp;gt;);
  Counter=Input(Substr(Filename,Find(Filename,'.')-2,2),2.)+1;
  Call SymputX('Counter',Counter);
Run;
%Put **&amp;amp;Counter.***;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 27 Sep 2016 06:19:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-add-running-serial-number-in-out-file-while-using-proc/m-p/300929#M60572</guid>
      <dc:creator>user24feb</dc:creator>
      <dc:date>2016-09-27T06:19:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to add running serial number in out file while using proc export</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-add-running-serial-number-in-out-file-while-using-proc/m-p/300958#M60573</link>
      <description>&lt;P&gt;Am not sure that is the best approach. &amp;nbsp;If you absolutely have to create separate files (and that would be my first pushback), and they abosultely have to have data in the filename (again, another pushback), then why not use a full date/timestamp and forget about incrementals? &amp;nbsp;You can simply export your data as:&lt;/P&gt;
&lt;PRE&gt;proc export data=work.test 
  outfile="c:\desktop\uma%sysfunc(date()date.)_%sysfunc(time(),tod8.).csv"
  dbms=csv;
quit;&lt;/PRE&gt;
&lt;P&gt;Note, its a good idea to have the file extension show what the file contains, txt = text, csv= csv.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Sep 2016 08:57:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-add-running-serial-number-in-out-file-while-using-proc/m-p/300958#M60573</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-09-27T08:57:23Z</dc:date>
    </item>
  </channel>
</rss>

