<?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: Write Out same file to different locations in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Write-Out-same-file-to-different-locations/m-p/293734#M61207</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can do something like this:&lt;/P&gt;
&lt;PRE&gt;data _null_;&lt;BR /&gt; set sashelp.class;&lt;BR /&gt; file 's:\temp\rob\test1.txt';&lt;BR /&gt; put _all_;&lt;BR /&gt; file 's:\temp\rob\test2.txt';&lt;BR /&gt; put _all_;&lt;BR /&gt;run;&lt;/PRE&gt;
&lt;P&gt;You can put as many file and put statements as you like.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why are you using .dat extension by the way? &amp;nbsp;Use a descriptive file extension, so maybe .txt as it is textual file format, or .csv for comma separated.&lt;/P&gt;</description>
    <pubDate>Wed, 24 Aug 2016 14:26:54 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2016-08-24T14:26:54Z</dc:date>
    <item>
      <title>Write Out same file to different locations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Write-Out-same-file-to-different-locations/m-p/293727#M61204</link>
      <description>&lt;P&gt;How do i write out the same file to different locations?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Eg, i tried 2 file statements, but i realised the file in the first statement is empty.&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;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;SPAN class="strong"&gt;FILENAME&lt;/SPAN&gt; OUT 'C:\desktop\dataset1.dat'&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;SPAN class="strong"&gt;FILENAME&lt;/SPAN&gt; OUT1 'C:\desktop\data\dataset1.dat'&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&amp;nbsp;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&amp;nbsp;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;'&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&amp;nbsp;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;BR /&gt;&lt;BR /&gt;data out; Set dataset1; File out; File out1; put @1 variable1; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;
&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Aug 2016 14:12:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Write-Out-same-file-to-different-locations/m-p/293727#M61204</guid>
      <dc:creator>apple</dc:creator>
      <dc:date>2016-08-24T14:12:47Z</dc:date>
    </item>
    <item>
      <title>Re: Write Out same file to different locations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Write-Out-same-file-to-different-locations/m-p/293730#M61206</link>
      <description>&lt;P&gt;You can only write to one file at any given moment; that is why the first file is empty, as the second file statement takes precedence.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is where a macro may be handy to avoid writing several data steps:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro write_file(outfilename);
data _null_;
set dataset1;
file "&amp;amp;outfilename";
put @1 variable1;
run;
%mend;
%write_file(C:\desktop\dataset\out);
%write_file(C:\desktop\out);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 24 Aug 2016 14:15:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Write-Out-same-file-to-different-locations/m-p/293730#M61206</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-08-24T14:15:19Z</dc:date>
    </item>
    <item>
      <title>Re: Write Out same file to different locations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Write-Out-same-file-to-different-locations/m-p/293734#M61207</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can do something like this:&lt;/P&gt;
&lt;PRE&gt;data _null_;&lt;BR /&gt; set sashelp.class;&lt;BR /&gt; file 's:\temp\rob\test1.txt';&lt;BR /&gt; put _all_;&lt;BR /&gt; file 's:\temp\rob\test2.txt';&lt;BR /&gt; put _all_;&lt;BR /&gt;run;&lt;/PRE&gt;
&lt;P&gt;You can put as many file and put statements as you like.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why are you using .dat extension by the way? &amp;nbsp;Use a descriptive file extension, so maybe .txt as it is textual file format, or .csv for comma separated.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Aug 2016 14:26:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Write-Out-same-file-to-different-locations/m-p/293734#M61207</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-08-24T14:26:54Z</dc:date>
    </item>
    <item>
      <title>Re: Write Out same file to different locations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Write-Out-same-file-to-different-locations/m-p/293921#M61278</link>
      <description>&lt;PRE&gt;
If you can use OS comman , you can copy any number of file:

x  " copy c:\temp\rob\test1.txt  c:\temp\rob\test2.txt  ";


&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Aug 2016 02:45:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Write-Out-same-file-to-different-locations/m-p/293921#M61278</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-08-25T02:45:45Z</dc:date>
    </item>
  </channel>
</rss>

