<?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 Copying and renaming a XLSX file using SAS 9.3 in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Copying-and-renaming-a-XLSX-file-using-SAS-9-3/m-p/305314#M60914</link>
    <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I use the following&amp;nbsp;program to&amp;nbsp;export a SAS dataset to an XLSX template workbook:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc export 
data=work.dataset
file="/directory/Workbook Template"
dbms=XLSX
replace
label;
sheet='Data';&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;However, the next step I would like is for the the workbook to be copied (so I keep the original template) and rename the workbook just created with something like "Workbook &amp;amp;SYSDATE.xslx"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried the solution to &lt;A href="https://communities.sas.com/t5/SAS-Procedures/Copying-and-renaming-a-file/m-p/17715#M3396" target="_blank"&gt;this&lt;/A&gt; post with no success and also tried the following code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
infile "/directory/Workbook Template.xlsx" lrecl=32767;
file "/directory/Workbook &amp;amp;RPT_DT_CHAR..xlsx";
input;
put _infile_;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Yet this corrupts the workbook and renders it unopenable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone have a solution to this problem that they could share with me please?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ed&lt;/P&gt;</description>
    <pubDate>Tue, 18 Oct 2016 08:39:10 GMT</pubDate>
    <dc:creator>edmb</dc:creator>
    <dc:date>2016-10-18T08:39:10Z</dc:date>
    <item>
      <title>Copying and renaming a XLSX file using SAS 9.3</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Copying-and-renaming-a-XLSX-file-using-SAS-9-3/m-p/305314#M60914</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I use the following&amp;nbsp;program to&amp;nbsp;export a SAS dataset to an XLSX template workbook:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc export 
data=work.dataset
file="/directory/Workbook Template"
dbms=XLSX
replace
label;
sheet='Data';&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;However, the next step I would like is for the the workbook to be copied (so I keep the original template) and rename the workbook just created with something like "Workbook &amp;amp;SYSDATE.xslx"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried the solution to &lt;A href="https://communities.sas.com/t5/SAS-Procedures/Copying-and-renaming-a-file/m-p/17715#M3396" target="_blank"&gt;this&lt;/A&gt; post with no success and also tried the following code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
infile "/directory/Workbook Template.xlsx" lrecl=32767;
file "/directory/Workbook &amp;amp;RPT_DT_CHAR..xlsx";
input;
put _infile_;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Yet this corrupts the workbook and renders it unopenable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone have a solution to this problem that they could share with me please?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ed&lt;/P&gt;</description>
      <pubDate>Tue, 18 Oct 2016 08:39:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Copying-and-renaming-a-XLSX-file-using-SAS-9-3/m-p/305314#M60914</guid>
      <dc:creator>edmb</dc:creator>
      <dc:date>2016-10-18T08:39:10Z</dc:date>
    </item>
    <item>
      <title>Re: Copying and renaming a XLSX file using SAS 9.3</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Copying-and-renaming-a-XLSX-file-using-SAS-9-3/m-p/305319#M60915</link>
      <description>&lt;P&gt;Try an X command statement&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;x 'copy "path to file1" "path to new file"';&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Oct 2016 09:25:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Copying-and-renaming-a-XLSX-file-using-SAS-9-3/m-p/305319#M60915</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-10-18T09:25:16Z</dc:date>
    </item>
    <item>
      <title>Re: Copying and renaming a XLSX file using SAS 9.3</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Copying-and-renaming-a-XLSX-file-using-SAS-9-3/m-p/305320#M60916</link>
      <description>&lt;P&gt;An XLSX file is actually a ZIP file with lots of contents. &amp;nbsp;Hence reading/writing it as character will result in a corrupt file. &amp;nbsp;You need to read/write as byte per Chris's post here:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.sas.com/content/sasdummy/2011/06/17/how-to-use-sas-data-step-to-copy-a-file-from-anywhere/" target="_blank"&gt;http://blogs.sas.com/content/sasdummy/2011/06/17/how-to-use-sas-data-step-to-copy-a-file-from-anywhere/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To use datastep method.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza﻿&lt;/a&gt;&amp;nbsp;has said you could use OS commands via X if that is enabled. &amp;nbsp;Alternatively just export the file twice.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Oct 2016 09:40:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Copying-and-renaming-a-XLSX-file-using-SAS-9-3/m-p/305320#M60916</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-10-18T09:40:40Z</dc:date>
    </item>
    <item>
      <title>Re: Copying and renaming a XLSX file using SAS 9.3</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Copying-and-renaming-a-XLSX-file-using-SAS-9-3/m-p/305380#M60917</link>
      <description>&lt;P&gt;Cheers to you both, though Chris's method in RW9's post worked the best for me.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Oct 2016 14:10:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Copying-and-renaming-a-XLSX-file-using-SAS-9-3/m-p/305380#M60917</guid>
      <dc:creator>edmb</dc:creator>
      <dc:date>2016-10-18T14:10:50Z</dc:date>
    </item>
  </channel>
</rss>

