<?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 dynamic files from one folder to another in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Copy-dynamic-files-from-one-folder-to-another/m-p/754311#M29958</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let pathscr = \\files\FEB_P000\Reporting_FS\Accounting log;
%let pathdes = \\files\FEB_P000\Reporting_FS\Accounting log\2021;

data _null_;
  length fref $8 fname $256;
  did = filename(fref,"&amp;amp;pathsrc");
  did = dopen(fref);
  do i = 1 to dnum(did);
    fname = dread(did,i);
    if find(FNAME,'.csv ') then do;
      rc1=filename('src',catx('\',"&amp;amp;pathscr",fname));
      rc2=filename('des',catx('\',"&amp;amp;pathdes",fname));
      rc3=fcopy('src','des');
    end;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 15 Jul 2021 13:03:05 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2021-07-15T13:03:05Z</dc:date>
    <item>
      <title>Copy dynamic files from one folder to another</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Copy-dynamic-files-from-one-folder-to-another/m-p/754271#M29953</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;I would like to copy all csv files from a specific folder to another one.&lt;/P&gt;&lt;P&gt;Below is the code which I am currently using:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;data _null_;&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt;length fref $8 fname $200;&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt;did = filename(fref,'\\files\FEB_P000\Reporting_FS\Accounting log');&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt;did = dopen(fref);&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt;do i = 1 to dnum(did);&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt;fname = dread(did,i);&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt;IF find(FNAME,'.csv') then&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; do;&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;%let pathscr = //files/FEB_P000/Reporting_FS/Accounting log;&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;%let pathdes = //files/FEB_P000/Reporting_FS/Accounting log/2021;&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;%let file = FNAME;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;libname IN "&amp;amp;pathscr";&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;libname IN "&amp;amp;pathdes";&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; filename src "&amp;amp;pathscr/&amp;amp;file";&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; filename des "&amp;amp;pathdes/&amp;amp;file";&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; rc= fcopy('src','des')&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;put rc=;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp;end;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;end;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;run;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However when is executes, no error is displayed (rc= 20006) but the files are not copied.&lt;/P&gt;&lt;P&gt;When I hard code the variable '&amp;amp;file' with the exact file name, the file is copied.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone help please?&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jul 2021 10:55:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Copy-dynamic-files-from-one-folder-to-another/m-p/754271#M29953</guid>
      <dc:creator>hanrhub</dc:creator>
      <dc:date>2021-07-15T10:55:42Z</dc:date>
    </item>
    <item>
      <title>Re: Copy dynamic files from one folder to another</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Copy-dynamic-files-from-one-folder-to-another/m-p/754302#M29954</link>
      <description>&lt;P&gt;You appear to have placed some macro code into the middle of your data step.&amp;nbsp; Since the data step does not run until after the macro processor has finished pre-processing the code and passing it to SAS itself to compile and run you should move those macro statements to BEFORE the DATA statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Same applies to the global statements (LIBNAME and FILENAME).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to define a libname or a filename based on values you have in data use the LIBNAME() or FILENAME() functions.&amp;nbsp; Not the LIBNAME or FILENAME statements.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jul 2021 12:41:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Copy-dynamic-files-from-one-folder-to-another/m-p/754302#M29954</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-07-15T12:41:02Z</dc:date>
    </item>
    <item>
      <title>Re: Copy dynamic files from one folder to another</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Copy-dynamic-files-from-one-folder-to-another/m-p/754305#M29955</link>
      <description>&lt;P&gt;Do you have to use sas for this task? In a data step you need to use the filename function, not the filename statement.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jul 2021 12:45:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Copy-dynamic-files-from-one-folder-to-another/m-p/754305#M29955</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-07-15T12:45:08Z</dc:date>
    </item>
    <item>
      <title>Re: Copy dynamic files from one folder to another</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Copy-dynamic-files-from-one-folder-to-another/m-p/754306#M29956</link>
      <description>&lt;P&gt;Are you running this SAS code on Windows operating system of Unix?&amp;nbsp; You can check the value of the SYSSCP macro variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Make sure the paths you use are consistent with where SAS is running.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jul 2021 12:47:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Copy-dynamic-files-from-one-folder-to-another/m-p/754306#M29956</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-07-15T12:47:31Z</dc:date>
    </item>
    <item>
      <title>Re: Copy dynamic files from one folder to another</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Copy-dynamic-files-from-one-folder-to-another/m-p/754310#M29957</link>
      <description>Hello Tom,&lt;BR /&gt;&lt;BR /&gt;Thanks for the explanations!&lt;BR /&gt;I am running it on Windows OS.&lt;BR /&gt;&lt;BR /&gt;Could you propose me with the right solution in terms of my codes displayed above?&lt;BR /&gt;&lt;BR /&gt;Thanks again</description>
      <pubDate>Thu, 15 Jul 2021 12:52:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Copy-dynamic-files-from-one-folder-to-another/m-p/754310#M29957</guid>
      <dc:creator>hanrhub</dc:creator>
      <dc:date>2021-07-15T12:52:15Z</dc:date>
    </item>
    <item>
      <title>Re: Copy dynamic files from one folder to another</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Copy-dynamic-files-from-one-folder-to-another/m-p/754311#M29958</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let pathscr = \\files\FEB_P000\Reporting_FS\Accounting log;
%let pathdes = \\files\FEB_P000\Reporting_FS\Accounting log\2021;

data _null_;
  length fref $8 fname $256;
  did = filename(fref,"&amp;amp;pathsrc");
  did = dopen(fref);
  do i = 1 to dnum(did);
    fname = dread(did,i);
    if find(FNAME,'.csv ') then do;
      rc1=filename('src',catx('\',"&amp;amp;pathscr",fname));
      rc2=filename('des',catx('\',"&amp;amp;pathdes",fname));
      rc3=fcopy('src','des');
    end;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 Jul 2021 13:03:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Copy-dynamic-files-from-one-folder-to-another/m-p/754311#M29958</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-07-15T13:03:05Z</dc:date>
    </item>
    <item>
      <title>Re: Copy dynamic files from one folder to another</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Copy-dynamic-files-from-one-folder-to-another/m-p/754312#M29959</link>
      <description>&lt;P&gt;See other post with code.&lt;/P&gt;
&lt;P&gt;Since you are running on Windows you might want to make your search for CSV extension case insensitve.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;find(FNAME,'.csv ','i')&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 Jul 2021 12:59:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Copy-dynamic-files-from-one-folder-to-another/m-p/754312#M29959</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-07-15T12:59:23Z</dc:date>
    </item>
    <item>
      <title>Re: Copy dynamic files from one folder to another</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Copy-dynamic-files-from-one-folder-to-another/m-p/754314#M29960</link>
      <description>Thanks a lot Tom!&lt;BR /&gt;It worked as expected &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 15 Jul 2021 13:03:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Copy-dynamic-files-from-one-folder-to-another/m-p/754314#M29960</guid>
      <dc:creator>hanrhub</dc:creator>
      <dc:date>2021-07-15T13:03:20Z</dc:date>
    </item>
  </channel>
</rss>

