<?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: how to copy multple files from one location to another where the date within the filename change in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-copy-multple-files-from-one-location-to-another-where-the/m-p/275656#M55138</link>
    <description>&lt;P&gt;Thanks for the responses guys but I really need to do it in SAS as the final program needs to put into an automated production for a monthly report. I should be able to use the wzinzip and copy functions but it's just identifying the filenames that contain the month of May, or whatever it would be at the time of the scheduled run.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Louise&lt;/P&gt;</description>
    <pubDate>Tue, 07 Jun 2016 13:30:27 GMT</pubDate>
    <dc:creator>LouiseH2010</dc:creator>
    <dc:date>2016-06-07T13:30:27Z</dc:date>
    <item>
      <title>how to copy multple files from one location to another where the date within the filename changes?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-copy-multple-files-from-one-location-to-another-where-the/m-p/275625#M55132</link>
      <description>&lt;P&gt;I need to copy mutiple files from one location to another where the date within the filename changes on a daily basis and I would need to copy a whole months worth at a time. There could also be other files with a different month within the date part that I don't want to copy.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Typical file names would be File_01May2016.zip, File_07May2016.zip, File_09May2016.zip, File_11May2016.zip, File_01Jun2016.zip. I would want to copy tghe four files containing the value May2016 (which I have set in a macro field called &amp;amp;MONTH) into a location where the directory is called 'MAY2016.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Once they have been copied to the correct location I need to unzip all the files within that new location.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any advice on how to code this would be much appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Louise&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jun 2016 11:41:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-copy-multple-files-from-one-location-to-another-where-the/m-p/275625#M55132</guid>
      <dc:creator>LouiseH2010</dc:creator>
      <dc:date>2016-06-07T11:41:23Z</dc:date>
    </item>
    <item>
      <title>Re: how to copy multple files from one location to another where the date within the filename change</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-copy-multple-files-from-one-location-to-another-where-the/m-p/275629#M55134</link>
      <description>&lt;P&gt;Hi Louise,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS can do a lot, and most of it is done very well indeed. But in this scenario SAS may not be the best tool. I would consider a script of some sort on the operating system (we would like to know which one anyways) as the way to go. That script could in turn be executed from SAS if you like but SAS would add very little benefit. And if copying is done by SAS then the unzipping would be a real challenge.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;- Jan.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jun 2016 12:14:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-copy-multple-files-from-one-location-to-another-where-the/m-p/275629#M55134</guid>
      <dc:creator>jklaverstijn</dc:creator>
      <dc:date>2016-06-07T12:14:00Z</dc:date>
    </item>
    <item>
      <title>Re: how to copy multple files from one location to another where the date within the filename change</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-copy-multple-files-from-one-location-to-another-where-the/m-p/275650#M55137</link>
      <description>&lt;P&gt;Look at this:&lt;/P&gt;
&lt;PRE&gt;cd sourcelocation
DATE=$1
mkdir targetlocation/${DATE}
for FILE in *${DATE}*.zip;do
  cp $FILE targetlocation/${DATE}
  unzip targetlocation/${DATE}/${FILE}
done&lt;/PRE&gt;
&lt;P&gt;This is a sample UNIX shell script that does what you want. Doing the same in SAS would be much more complicated.&lt;/P&gt;
&lt;P&gt;Use the right tool for the job.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jun 2016 13:19:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-copy-multple-files-from-one-location-to-another-where-the/m-p/275650#M55137</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-06-07T13:19:25Z</dc:date>
    </item>
    <item>
      <title>Re: how to copy multple files from one location to another where the date within the filename change</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-copy-multple-files-from-one-location-to-another-where-the/m-p/275656#M55138</link>
      <description>&lt;P&gt;Thanks for the responses guys but I really need to do it in SAS as the final program needs to put into an automated production for a monthly report. I should be able to use the wzinzip and copy functions but it's just identifying the filenames that contain the month of May, or whatever it would be at the time of the scheduled run.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Louise&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jun 2016 13:30:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-copy-multple-files-from-one-location-to-another-where-the/m-p/275656#M55138</guid>
      <dc:creator>LouiseH2010</dc:creator>
      <dc:date>2016-06-07T13:30:27Z</dc:date>
    </item>
    <item>
      <title>Re: how to copy multple files from one location to another where the date within the filename change</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-copy-multple-files-from-one-location-to-another-where-the/m-p/275665#M55142</link>
      <description>&lt;P&gt;So which system is it? UNIX or WIndows?&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jun 2016 13:43:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-copy-multple-files-from-one-location-to-another-where-the/m-p/275665#M55142</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-06-07T13:43:49Z</dc:date>
    </item>
    <item>
      <title>Re: how to copy multple files from one location to another where the date within the filename change</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-copy-multple-files-from-one-location-to-another-where-the/m-p/275666#M55143</link>
      <description>&lt;P&gt;The system we use is Windows&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jun 2016 13:48:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-copy-multple-files-from-one-location-to-another-where-the/m-p/275666#M55143</guid>
      <dc:creator>LouiseH2010</dc:creator>
      <dc:date>2016-06-07T13:48:58Z</dc:date>
    </item>
    <item>
      <title>Re: how to copy multple files from one location to another where the date within the filename change</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-copy-multple-files-from-one-location-to-another-where-the/m-p/275670#M55145</link>
      <description>&lt;P&gt;Ok, let's try&lt;/P&gt;
&lt;P&gt;Initialize:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let sourcepath=where_your_files_are;
%let targetpath=where_you_want_them;
%let month=MAY2016;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Create a dataset with file names:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename oscmd pipe "dir &amp;amp;sourcepath.\*&amp;amp;month.*.zip";

data filenames;
length fname $254;
infile oscmd;
input fname;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now act on that&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
set filenames;
if _n_ = 1 then call system("mkdir &amp;amp;targetpath.\&amp;amp;month");
call system("copy " !! fname !! " &amp;amp;targetpath.\&amp;amp;month");
fname = scan(fname,-1,'\');
call system("winzip32 -e &amp;amp;targetpath.\&amp;amp;month.\" !! fname);
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 Jun 2016 14:02:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-copy-multple-files-from-one-location-to-another-where-the/m-p/275670#M55145</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-06-07T14:02:08Z</dc:date>
    </item>
    <item>
      <title>Re: how to copy multple files from one location to another where the date within the filename change</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-copy-multple-files-from-one-location-to-another-where-the/m-p/277158#M55605</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks to everyone that posted a suggestion - we have managed to solve the issue ourselves in the end but all suggestions much appreciated.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jun 2016 08:32:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-copy-multple-files-from-one-location-to-another-where-the/m-p/277158#M55605</guid>
      <dc:creator>LouiseH2010</dc:creator>
      <dc:date>2016-06-14T08:32:10Z</dc:date>
    </item>
    <item>
      <title>Re: how to copy multple files from one location to another where the date within the filename change</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-copy-multple-files-from-one-location-to-another-where-the/m-p/277195#M55623</link>
      <description>&lt;P&gt;&amp;nbsp;Out of cusiosity and always looking for a learning opportunity, could you share your solution with us?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;- Jan.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jun 2016 12:14:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-copy-multple-files-from-one-location-to-another-where-the/m-p/277195#M55623</guid>
      <dc:creator>jklaverstijn</dc:creator>
      <dc:date>2016-06-14T12:14:28Z</dc:date>
    </item>
    <item>
      <title>Re: how to copy multple files from one location to another where the date within the filename change</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-copy-multple-files-from-one-location-to-another-where-the/m-p/277244#M55643</link>
      <description>&lt;P&gt;As requested:&lt;/P&gt;&lt;P&gt;/*set file locations from and to*/&lt;BR /&gt;%let statement_fm = &amp;amp;wr\XXXX\XXXX;&lt;BR /&gt;%let statement_to = &amp;amp;wr\XXXX\XXXX\&amp;amp;MONTH;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;Data List_files (keep =&amp;nbsp; filevar);&lt;BR /&gt;&amp;nbsp;rc=FILENAME('stmnts',"&amp;amp;file_fm");&lt;BR /&gt;&amp;nbsp;did=DOPEN('stmnts');&lt;BR /&gt;&amp;nbsp;memcnt=DNUM(did);&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;*count number of members&amp;nbsp; - including subfolders;&lt;BR /&gt;&amp;nbsp;DO i=1 TO memcnt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;*for each member, test extension and store filename;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;filevar=(DREAD(did,i));&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;IF LOWCASE(SCAN(filevar,-1,".")) EQ LOWCASE("zip") THEN&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;OUTPUT;&lt;BR /&gt;&amp;nbsp;END;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;rc=DCLOSE(did);&lt;BR /&gt;&amp;nbsp;rc=FILENAME('stmnts');&lt;BR /&gt;Run;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;&amp;nbsp;select&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;filevar, count(*)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;into: file1-,: obs&lt;BR /&gt;&amp;nbsp;from work.list_files(where=(lowcase(filevar) like "%%&amp;amp;monthname.%"));&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;%macro copy_files;&lt;BR /&gt;&amp;nbsp;%do i=1 %to &amp;amp;obs.;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;%put &amp;amp;&amp;amp;file&amp;amp;i.;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;%sysexec move "&amp;amp;file_fm\&amp;amp;&amp;amp;file&amp;amp;i." "&amp;amp;file_to\&amp;amp;&amp;amp;file&amp;amp;i.";&lt;BR /&gt;&amp;nbsp;%end;&lt;BR /&gt;%mend;&lt;/P&gt;&lt;P&gt;%copy_files;&lt;/P&gt;&lt;P&gt;%macro unzip_files;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %do i=1 %to &amp;amp;obs.;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %put &amp;amp;&amp;amp;file&amp;amp;i.;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;%sysexec wzunzip "&amp;amp;file_to\&amp;amp;&amp;amp;file&amp;amp;i." "&amp;amp;file_to\" -d;&lt;BR /&gt;&amp;nbsp;%end;&lt;BR /&gt;%mend;&lt;/P&gt;&lt;P&gt;%unzip_files;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jun 2016 14:18:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-copy-multple-files-from-one-location-to-another-where-the/m-p/277244#M55643</guid>
      <dc:creator>LouiseH2010</dc:creator>
      <dc:date>2016-06-14T14:18:12Z</dc:date>
    </item>
  </channel>
</rss>

