<?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: Macros within fcopy in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Macros-within-fcopy/m-p/513505#M2540</link>
    <description>Do you already have the filenames in a a data set? If so you don't need a macro at all. Use FCOPY within the data step directly. Your code stays almost the same. &lt;BR /&gt;&lt;BR /&gt;1. add a set statement to point to the data set with the filenames. &lt;BR /&gt;2. Change the files name using string functions instead of macro functions&lt;BR /&gt;3. Pass the variables to the FCOPY directly. &lt;BR /&gt;</description>
    <pubDate>Thu, 15 Nov 2018 18:34:14 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-11-15T18:34:14Z</dc:date>
    <item>
      <title>Macros within fcopy</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Macros-within-fcopy/m-p/513495#M2536</link>
      <description>&lt;P&gt;I have 10 files in one directory in FTP which has to be moved to another directory in FTP. For file move process I'm using Fcopy.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For all the 10files -starting of the filename is common (Report), Only the datepart and endpart of the file changes every month. I defiend datepart and endpart of the filenames to macro as the endpart of the filename are saved in table data as fname.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Filename examples :&lt;/P&gt;&lt;P&gt;1. Report_31-10-2018_wind.xlsx&lt;/P&gt;&lt;P&gt;2. Report_31-10-2018_water.xlsx etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dataset : Data&lt;/P&gt;&lt;P&gt;fname&lt;/P&gt;&lt;P&gt;wind&lt;/P&gt;&lt;P&gt;water&lt;/P&gt;&lt;P&gt;health&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
	select count(fname) into:n trimmed from data;
	select distinct fname into:fn1 - :fn%left(&amp;amp;n)
			from data;
run;

data _null_;
	 call symput ('datepart',put(intnx('month',today(),0,"b"),yymmdd10.));
run;


data _null_;
			length msg $384;
			i=filename('in',"/temp/files/Report&amp;amp;datepart._&amp;amp;&amp;amp;fn&amp;amp;n..xlsx", "DISK", "RECFM=N");
			o=filename('out',"/temp/files/backup/Report&amp;amp;check._&amp;amp;&amp;amp;fn&amp;amp;n..xlsx", "DISK", "RECFM=N");

			rc=fcopy('_in', '_out');
				if rc=0 then
			put 'Copied _in to _out.';
				else do
					msg=sysmsg();
				  put rc= msg=;
	end;
i=filename('in');
o=filename('out');
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This code works perfect without errors. But moves only 1 file ie., fn10 file but not rest of the files.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can any advice what I'm missing here.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Nov 2018 18:02:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Macros-within-fcopy/m-p/513495#M2536</guid>
      <dc:creator>ashna</dc:creator>
      <dc:date>2018-11-15T18:02:59Z</dc:date>
    </item>
    <item>
      <title>Re: Macros within fcopy</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Macros-within-fcopy/m-p/513498#M2537</link>
      <description>N never changes  - you have no loop. You can use a data step with a do loop and make the string and then pass it to FCOPY or you can add a macro loop.</description>
      <pubDate>Thu, 15 Nov 2018 18:13:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Macros-within-fcopy/m-p/513498#M2537</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-11-15T18:13:26Z</dc:date>
    </item>
    <item>
      <title>Re: Macros within fcopy</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Macros-within-fcopy/m-p/513502#M2539</link>
      <description>&lt;P&gt;Can I define it as following&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro fend;
	%do i=1 %to 5;
		%put filename=&amp;amp;&amp;amp;fn&amp;amp;i;
	%end;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;And use fend instead of &amp;amp;fn&amp;amp;n in following statement?&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;i=filename('in',"/data/skynet/files/custom_billing/Cat/NSMIS/BNC/&amp;amp;cname&amp;amp;check._&amp;amp;fend..xlsx", "DISK", "RECFM=N");&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Nov 2018 18:27:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Macros-within-fcopy/m-p/513502#M2539</guid>
      <dc:creator>ashna</dc:creator>
      <dc:date>2018-11-15T18:27:33Z</dc:date>
    </item>
    <item>
      <title>Re: Macros within fcopy</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Macros-within-fcopy/m-p/513505#M2540</link>
      <description>Do you already have the filenames in a a data set? If so you don't need a macro at all. Use FCOPY within the data step directly. Your code stays almost the same. &lt;BR /&gt;&lt;BR /&gt;1. add a set statement to point to the data set with the filenames. &lt;BR /&gt;2. Change the files name using string functions instead of macro functions&lt;BR /&gt;3. Pass the variables to the FCOPY directly. &lt;BR /&gt;</description>
      <pubDate>Thu, 15 Nov 2018 18:34:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Macros-within-fcopy/m-p/513505#M2540</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-11-15T18:34:14Z</dc:date>
    </item>
    <item>
      <title>Re: Macros within fcopy</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Macros-within-fcopy/m-p/513523#M2547</link>
      <description>&lt;P&gt;Thanks, for the advice,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was over think for the simple solution &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Nov 2018 19:10:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Macros-within-fcopy/m-p/513523#M2547</guid>
      <dc:creator>ashna</dc:creator>
      <dc:date>2018-11-15T19:10:02Z</dc:date>
    </item>
  </channel>
</rss>

