<?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 the file with rename in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Copy-the-file-with-rename/m-p/902579#M356700</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data results;
  set pdf_corr;
  length src dst $ 8 ;&lt;BR /&gt;&lt;BR /&gt;  *create path to files;
  source_file =catt("\\xxxxx\PDF_20230427\", NOM_PDF1); 
  dest_file = catt("\\xxxxx\PDF_20230427_V2\", NOM_PDF1);&lt;BR /&gt;&lt;BR /&gt;  *create filerefs for copy function;
  rc1=filename(src,source_file,,'recfm=n');
  rc2=filename(dst,dest_file,,'recfm=n');&lt;BR /&gt;&lt;BR /&gt;  *copy;
  rc3=fcopy(src,dst);&lt;BR /&gt;&lt;BR /&gt;  *deassign filerefs;
  rc4=filename(src);
  rc5=filename(dst);&lt;BR /&gt;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 10 Nov 2023 19:04:42 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2023-11-10T19:04:42Z</dc:date>
    <item>
      <title>Copy the file with rename</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Copy-the-file-with-rename/m-p/902571#M356698</link>
      <description>&lt;P&gt;Hello Experts,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Actually, I rename the file with move statement :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;	proc sort data=pdf_corr nodupkey;
				by NOM_PDF1;
			run;

			DATA _null_;
				call symputx ('nb', nobs);
				SET pdf_corr nobs=nobs;
			run;

			%put valeur &amp;amp;nb.;

			%do i=1 %to &amp;amp;nb.;

				data _NULL_;
					set pdf_corr(obs=&amp;amp;i);
					CALL SYMPUTX(COMPRESS('PDFACOL_CORR_ANO'),NOM_PDF);
					CALL SYMPUTX(COMPRESS('PDFACOL_CORR'),NOM_PDF1);
				run;

				option xwait xsync;
				X move "\\xxxxxx\PDF_20230427\&amp;amp;PDFACOL_CORR_ANO."    
					"\\xxxxxxx\PDF_20230427_V2\&amp;amp;PDFACOL_CORR.";
			%end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I would like to rename the file by creating multiple documents, for example, if I have the file LPKPT.pdf I would like to rename this file on LPKP_M2.pdf, LKP_E.pdf. Do I need to use the copy statement ?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Precisely, I have one file in one side and I would like to copy this file into multiple files. Is it possible?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your help!&lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2023 19:54:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Copy-the-file-with-rename/m-p/902571#M356698</guid>
      <dc:creator>SASdevAnneMarie</dc:creator>
      <dc:date>2023-11-10T19:54:07Z</dc:date>
    </item>
    <item>
      <title>Re: Copy the file with rename</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Copy-the-file-with-rename/m-p/902578#M356699</link>
      <description>It would be easier to use FCOPY and FILENAME as then you don't need the macro loop or x command.  &lt;BR /&gt;&lt;BR /&gt;Alternatively if you're moving all files in the folder, you can use a wildcard operator in the x move statement instead.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 10 Nov 2023 18:59:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Copy-the-file-with-rename/m-p/902578#M356699</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-11-10T18:59:44Z</dc:date>
    </item>
    <item>
      <title>Re: Copy the file with rename</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Copy-the-file-with-rename/m-p/902579#M356700</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data results;
  set pdf_corr;
  length src dst $ 8 ;&lt;BR /&gt;&lt;BR /&gt;  *create path to files;
  source_file =catt("\\xxxxx\PDF_20230427\", NOM_PDF1); 
  dest_file = catt("\\xxxxx\PDF_20230427_V2\", NOM_PDF1);&lt;BR /&gt;&lt;BR /&gt;  *create filerefs for copy function;
  rc1=filename(src,source_file,,'recfm=n');
  rc2=filename(dst,dest_file,,'recfm=n');&lt;BR /&gt;&lt;BR /&gt;  *copy;
  rc3=fcopy(src,dst);&lt;BR /&gt;&lt;BR /&gt;  *deassign filerefs;
  rc4=filename(src);
  rc5=filename(dst);&lt;BR /&gt;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 10 Nov 2023 19:04:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Copy-the-file-with-rename/m-p/902579#M356700</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-11-10T19:04:42Z</dc:date>
    </item>
    <item>
      <title>Re: Copy the file with rename</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Copy-the-file-with-rename/m-p/902586#M356701</link>
      <description>Thank you Reeza! Actually, I have one file in one side and I would like to copy this file into multiple files. Is it possible?</description>
      <pubDate>Fri, 10 Nov 2023 19:52:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Copy-the-file-with-rename/m-p/902586#M356701</guid>
      <dc:creator>SASdevAnneMarie</dc:creator>
      <dc:date>2023-11-10T19:52:22Z</dc:date>
    </item>
    <item>
      <title>Re: Copy the file with rename</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Copy-the-file-with-rename/m-p/902590#M356702</link>
      <description>Sure, just do multiple calls to fcopy with the different file references. You may need to also do the filename statements again to create the references.</description>
      <pubDate>Fri, 10 Nov 2023 20:24:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Copy-the-file-with-rename/m-p/902590#M356702</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-11-10T20:24:14Z</dc:date>
    </item>
    <item>
      <title>Re: Copy the file with rename</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Copy-the-file-with-rename/m-p/902592#M356703</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data results;
  set pdf_corr;
  length src dst dst2 $ 8 ;  *create path to files;
  source_file =catt("\\xxxxx\PDF_20230427\", NOM_PDF1); 
  dest_file = catt("\\xxxxx\PDF_20230427_V2\", NOM_PDF1);  *create filerefs for copy function;
dest_file2 =   dest_file = catt("\\xxxxx\PDF_20230427_V2\", NOM_PDF2); 
  rc1=filename(src,source_file,,'recfm=n');
  rc2=filename(dst,dest_file,,'recfm=n');  
  rc2_1 = filename(dst2, dest_file2, , 'recfm=n');

  rc3_1=fcopy(src,dst);  *deassign filerefs;
  rc3_2=fcopy(src,dst2);  *deassign filerefs;

  rc4=filename(src);
  rc5=filename(dst);
  rc6 = filename(dst2);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Assuming you have another variable with the name, then the above is a brief example. If every file is copied multiple times you can generate those names and create a loop to loop over the names rather than repeat the code but it depends on exactly what you're doing.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2023 20:42:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Copy-the-file-with-rename/m-p/902592#M356703</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-11-10T20:42:14Z</dc:date>
    </item>
  </channel>
</rss>

