<?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: Bootstrapping need output file to be 001 not 1, etc. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Bootstrapping-need-output-file-to-be-001-not-1-etc/m-p/376261#M90289</link>
    <description>&lt;P&gt;Alternatively you can do:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if %length(&amp;amp;i) = 1 %then %let j = 00&amp;amp;i; %else
%if %length(&amp;amp;i) = 2 %then %let j=0&amp;amp;i; %else %let j = &amp;amp;i;

proc export data=out outfile="&amp;amp;out\&amp;amp;filename.&amp;amp;j..txt" dbms=csv replace; PUTNAMES=NO; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 15 Jul 2017 20:00:38 GMT</pubDate>
    <dc:creator>Shmuel</dc:creator>
    <dc:date>2017-07-15T20:00:38Z</dc:date>
    <item>
      <title>Bootstrapping need output file to be 001 not 1, etc.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Bootstrapping-need-output-file-to-be-001-not-1-etc/m-p/376258#M90287</link>
      <description>&lt;P&gt;Below is the code I am using, I wrote some of it and had assistance for the rest, so my knowledge is limited.&lt;/P&gt;&lt;P&gt;The program works fine but I need a small adjustment. For the output file I need the name to have 3 digits. So the first file would be auto001.txt currently it is auto1.txt.&lt;/P&gt;&lt;P&gt;(I could do this outside of SAS but I am going to be doing this in significant volume and would like to get it output in ready to use format)&lt;/P&gt;&lt;P&gt;It is the '&amp;amp;i' in the proc export statement that i need to write as 001 and not 1.&lt;/P&gt;&lt;P&gt;Any help much appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let in=n:\private\my documents\hypercompetition\IEEE submission\Excel Data;&lt;BR /&gt;%let out=n:\private\my documents\hypercompetition\IEEE submission\Excel Data\output1;&lt;BR /&gt;%let iterations=2;&lt;/P&gt;&lt;P&gt;proc datasets kill noprint;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%macro RandBetween(min, max);&lt;BR /&gt;(&amp;amp;min + floor((1+&amp;amp;max-&amp;amp;min)*rand("uniform")))&lt;BR /&gt;%mend;&lt;/P&gt;&lt;P&gt;%macro iter(filename, i);&lt;BR /&gt;data rnd;&lt;BR /&gt;set in;&lt;BR /&gt;if _n_=1;&lt;BR /&gt;x = %RandBetween (1, 8844);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data out;&lt;BR /&gt;if _n_=1 then set rnd;&lt;BR /&gt;set in;&lt;BR /&gt;obs=_n_;&lt;BR /&gt;if obs lt x then delete;&lt;BR /&gt;if obs gt x+998 then delete;&lt;BR /&gt;drop x obs;&lt;/P&gt;&lt;P&gt;proc export data=out outfile="&amp;amp;out\&amp;amp;filename.&amp;amp;i..txt" dbms=csv replace; PUTNAMES=NO; run;&lt;BR /&gt;%mend;&lt;/P&gt;&lt;P&gt;%macro main(filename);&lt;BR /&gt;proc import datafile="&amp;amp;in\&amp;amp;filename..txt" out=in dbms=csv replace; getnames = no; run;&lt;/P&gt;&lt;P&gt;%do i=1 %to &amp;amp;iterations;&lt;BR /&gt;%iter(&amp;amp;filename., &amp;amp;i.);&lt;/P&gt;&lt;P&gt;%end;&lt;BR /&gt;%mend;&lt;BR /&gt;%main(auto);&lt;/P&gt;</description>
      <pubDate>Sat, 15 Jul 2017 18:44:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Bootstrapping-need-output-file-to-be-001-not-1-etc/m-p/376258#M90287</guid>
      <dc:creator>Meature</dc:creator>
      <dc:date>2017-07-15T18:44:54Z</dc:date>
    </item>
    <item>
      <title>Re: Bootstrapping need output file to be 001 not 1, etc.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Bootstrapping-need-output-file-to-be-001-not-1-etc/m-p/376259#M90288</link>
      <description>&lt;P&gt;You want to apply the z3 format to the macro variable i, so try replacing&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc export data=out outfile="&amp;amp;out\&amp;amp;filename.&amp;amp;i..txt" dbms=csv replace;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;with&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc export data=out outfile="&amp;amp;out\&amp;amp;filename.%sysfunc(putn(&amp;amp;i,z3.))..txt" dbms=csv replace;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I used this bit of code to figure out the syntax:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let counter=100;

%macro test;
  %do i=1 %to &amp;amp;counter;
    %let file=file%sysfunc(putn(&amp;amp;i,z3.));
    %put FILE = &amp;amp;file..txt ;
  %end;
%mend test;

%test&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 15 Jul 2017 18:58:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Bootstrapping-need-output-file-to-be-001-not-1-etc/m-p/376259#M90288</guid>
      <dc:creator>SuzanneDorinski</dc:creator>
      <dc:date>2017-07-15T18:58:02Z</dc:date>
    </item>
    <item>
      <title>Re: Bootstrapping need output file to be 001 not 1, etc.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Bootstrapping-need-output-file-to-be-001-not-1-etc/m-p/376261#M90289</link>
      <description>&lt;P&gt;Alternatively you can do:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if %length(&amp;amp;i) = 1 %then %let j = 00&amp;amp;i; %else
%if %length(&amp;amp;i) = 2 %then %let j=0&amp;amp;i; %else %let j = &amp;amp;i;

proc export data=out outfile="&amp;amp;out\&amp;amp;filename.&amp;amp;j..txt" dbms=csv replace; PUTNAMES=NO; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 15 Jul 2017 20:00:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Bootstrapping-need-output-file-to-be-001-not-1-etc/m-p/376261#M90289</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-07-15T20:00:38Z</dc:date>
    </item>
    <item>
      <title>Re: Bootstrapping need output file to be 001 not 1, etc.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Bootstrapping-need-output-file-to-be-001-not-1-etc/m-p/376265#M90291</link>
      <description>&lt;P&gt;I'm so glad I found this board! My first post and I get a homerun response.&lt;/P&gt;&lt;P&gt;Suzanne the code you wrote work perfectly. Thank you.&lt;/P&gt;</description>
      <pubDate>Sat, 15 Jul 2017 20:17:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Bootstrapping-need-output-file-to-be-001-not-1-etc/m-p/376265#M90291</guid>
      <dc:creator>Meature</dc:creator>
      <dc:date>2017-07-15T20:17:13Z</dc:date>
    </item>
    <item>
      <title>Re: Bootstrapping need output file to be 001 not 1, etc.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Bootstrapping-need-output-file-to-be-001-not-1-etc/m-p/376266#M90292</link>
      <description>&lt;P&gt;Shmuel, thank you for your solution as well. I have copied your code for future reference.&lt;/P&gt;&lt;P&gt;Suzanne's solution did what I needed.&lt;/P&gt;</description>
      <pubDate>Sat, 15 Jul 2017 20:19:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Bootstrapping-need-output-file-to-be-001-not-1-etc/m-p/376266#M90292</guid>
      <dc:creator>Meature</dc:creator>
      <dc:date>2017-07-15T20:19:01Z</dc:date>
    </item>
  </channel>
</rss>

