<?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: Copy multiple files and rename within the same file in SAS EG in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Copy-multiple-files-and-rename-within-the-same-file-in-SAS-EG/m-p/479933#M31139</link>
    <description>&lt;P&gt;1. Create a list of files in the folders using SAS built in functions.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. Use the list of files to create filename references using the filename function instead of statement.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3. Call FCOPY for each line using the function within a data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15475"&gt;@andreas_lds&lt;/a&gt;&amp;nbsp;solution illustrates that.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 20 Jul 2018 16:07:19 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-07-20T16:07:19Z</dc:date>
    <item>
      <title>Copy multiple files and rename within the same file in SAS EG</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Copy-multiple-files-and-rename-within-the-same-file-in-SAS-EG/m-p/479819#M31134</link>
      <description>&lt;P&gt;Can someone please help me&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have three files that I want to copy and rename and place it in the same folder.&lt;/P&gt;&lt;P&gt;In Base SAS it worked with the following script&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; sub=1;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; dir=P:\Applications and Offers\sub1;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;options&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;noxwait&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%sysexec&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; copy &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"&amp;amp;dir.\*.&amp;amp;sub.00001"&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="2"&gt;"&amp;amp;dir.\*.&amp;amp;sub.00001_in"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; ;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;options&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;xwait&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;options&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;missing&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;""&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In SAS EG, fcopy&amp;nbsp;lets me copy 1 file but not multiple files&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;filename&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; filein &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"P:\Applications and Offers\sub1\*.100001"&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;recfm&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=n;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;filename&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; fileout &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"P:\Applications and Offers\sub1\*.100001_in"&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;recfm&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=n;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;_null_&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;rc=fcopy(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'filein'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;, &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'fileout'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;put&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; rc=;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;run&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The above code does not work. Obviously * is not recognised as it's a windows command. What can I substitute in SAS EG?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone have a solution?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jul 2018 07:10:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Copy-multiple-files-and-rename-within-the-same-file-in-SAS-EG/m-p/479819#M31134</guid>
      <dc:creator>LFranklin</dc:creator>
      <dc:date>2018-07-20T07:10:00Z</dc:date>
    </item>
    <item>
      <title>Re: Copy multiple files and rename within the same file in SAS EG</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Copy-multiple-files-and-rename-within-the-same-file-in-SAS-EG/m-p/479838#M31135</link>
      <description>&lt;P&gt;Looks as if you have to code iteration by using dopen, dread and filename function in a datastep.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Untested code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename dirRef "P:\Applications and Offers\sub1";

data filesToCopy;
   did = dopen('dirRef');

   do i = 1 to dnum(did);
      name = dread(did, i);
      
      if prxmatch('/.*\.100001$/', trim(name)) then do;
         output;
      end;
   end;

run;


data _null_;
   set filesToCopy;

   rc = filename('fin', name, , 'recfm=f', dirRef);
   rc = filename('fout', cats(name, '_in'), , 'recfm=f', dirRef);

   rc = fcopy('fin', 'fout');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 20 Jul 2018 09:07:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Copy-multiple-files-and-rename-within-the-same-file-in-SAS-EG/m-p/479838#M31135</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2018-07-20T09:07:06Z</dc:date>
    </item>
    <item>
      <title>Re: Copy multiple files and rename within the same file in SAS EG</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Copy-multiple-files-and-rename-within-the-same-file-in-SAS-EG/m-p/479933#M31139</link>
      <description>&lt;P&gt;1. Create a list of files in the folders using SAS built in functions.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. Use the list of files to create filename references using the filename function instead of statement.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3. Call FCOPY for each line using the function within a data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15475"&gt;@andreas_lds&lt;/a&gt;&amp;nbsp;solution illustrates that.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jul 2018 16:07:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Copy-multiple-files-and-rename-within-the-same-file-in-SAS-EG/m-p/479933#M31139</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-07-20T16:07:19Z</dc:date>
    </item>
    <item>
      <title>Re: Copy multiple files and rename within the same file in SAS EG</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Copy-multiple-files-and-rename-within-the-same-file-in-SAS-EG/m-p/480111#M31146</link>
      <description>&lt;P&gt;Hi Andreas,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The first part works&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;filename dirRef "P:\Applications and Offers\sub1";&amp;nbsp;data filesToCopy;&amp;nbsp;&amp;nbsp; did = dopen('dirRef');&amp;nbsp;&amp;nbsp;&amp;nbsp; do i = 1 to dnum(did);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; name = dread(did, i);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if prxmatch('/.*\.100001$/', trim(name)) then do;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&amp;nbsp;&amp;nbsp; end;&amp;nbsp;run;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;did&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; name&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1055OD2018.100001&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1055PD2018.100001&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1055AD2018.100001&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The second part does not work for me&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data _null_;&amp;nbsp;&amp;nbsp; set filesToCopy;&amp;nbsp;&amp;nbsp;&amp;nbsp; rc = filename('fin', name, , 'recfm=f', dirRef);&amp;nbsp;&amp;nbsp; rc = filename('fout', cats(name, '_in'), , 'recfm=f', dirRef);&amp;nbsp;&amp;nbsp;&amp;nbsp; rc = fcopy('fin', 'fout');run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;No errors but ignores the rename part&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;_______________________________________________________&lt;/P&gt;&lt;P&gt;The ideal output in ‘dirRef’ should be something like this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1055OD2018.100001&lt;/P&gt;&lt;P&gt;1055PD2018.100001&lt;/P&gt;&lt;P&gt;1055AD2018.100001&lt;/P&gt;&lt;P&gt;1055OD2018.100001_n&lt;/P&gt;&lt;P&gt;1055PD2018.100001_n&lt;/P&gt;&lt;P&gt;1055AD2018.100001_n&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am new to SAS EG&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for helping&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 21 Jul 2018 02:11:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Copy-multiple-files-and-rename-within-the-same-file-in-SAS-EG/m-p/480111#M31146</guid>
      <dc:creator>LFranklin</dc:creator>
      <dc:date>2018-07-21T02:11:29Z</dc:date>
    </item>
  </channel>
</rss>

