<?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: SAS fcopy failing to copy .xls file (creates corrupted 1KB file) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-fcopy-failing-to-copy-xls-file-creates-corrupted-1KB-file/m-p/987078#M380030</link>
    <description>&lt;P&gt;XLS files are BINARY files. So make sure to tell SAS that.&lt;/P&gt;
&lt;P&gt;You can try RECFM=N as suggested by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4"&gt;@ChrisHemedinger&lt;/a&gt;&amp;nbsp;'s blog post.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename in1 "H:\folder1\file1.xls" recfm=N;
filename ou1 "H:\folder2\file1.xls" recfm=N;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or use RECFM=F and LRECL=512.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 01 May 2026 16:19:36 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2026-05-01T16:19:36Z</dc:date>
    <item>
      <title>SAS fcopy failing to copy .xls file (creates corrupted 1KB file)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-fcopy-failing-to-copy-xls-file-creates-corrupted-1KB-file/m-p/987062#M380028</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;I’m trying to copy an Excel file (.xls) from one folder to another on the same drive using SAS, but I’m running into an issue.&lt;/P&gt;&lt;P&gt;Here’s the code I’m using:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;PRE class=""&gt;&lt;CODE&gt;&lt;SPAN&gt;filename in1 "H:\folder1\file1.xls";&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;filename ou1 "H:\folder2\file1.xls";&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;data _null_;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;  rc = fcopy("in1", "ou1");&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;  if rc = 0 then put 'Copy successful';&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;  else put 'Copy failed';&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;PRE class=""&gt;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;What’s happening:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;On the first run, a file does get created in the destination folder with today’s timestamp, but it’s corrupted and only ~1KB in size (original file is ~13KB).&lt;/LI&gt;&lt;LI&gt;I deleted the corrupted file and ran the code again, but this time no file was created at all.&lt;/LI&gt;&lt;LI&gt;In both cases, the log shows: &lt;STRONG&gt;“Copy failed”&lt;/STRONG&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Has anyone encountered this issue before or knows what might be causing fcopy to fail like this? Are there any additional checks or alternative approaches I should consider? Any troubleshooting ideas?&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 May 2026 14:40:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-fcopy-failing-to-copy-xls-file-creates-corrupted-1KB-file/m-p/987062#M380028</guid>
      <dc:creator>ussas_15</dc:creator>
      <dc:date>2026-05-01T14:40:49Z</dc:date>
    </item>
    <item>
      <title>Re: SAS fcopy failing to copy .xls file (creates corrupted 1KB file)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-fcopy-failing-to-copy-xls-file-creates-corrupted-1KB-file/m-p/987064#M380029</link>
      <description>&lt;P&gt;What version of SAS are you using? I know that FCOPY has improved in later versions to handle more cases.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But for an immediate solution of your problem, try an alternative approach to perform a binary copy of the file.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/sasdummy/2013/09/17/copy-file-macro/" target="_blank"&gt;https://blogs.sas.com/content/sasdummy/2013/09/17/copy-file-macro/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 May 2026 14:56:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-fcopy-failing-to-copy-xls-file-creates-corrupted-1KB-file/m-p/987064#M380029</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2026-05-01T14:56:26Z</dc:date>
    </item>
    <item>
      <title>Re: SAS fcopy failing to copy .xls file (creates corrupted 1KB file)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-fcopy-failing-to-copy-xls-file-creates-corrupted-1KB-file/m-p/987078#M380030</link>
      <description>&lt;P&gt;XLS files are BINARY files. So make sure to tell SAS that.&lt;/P&gt;
&lt;P&gt;You can try RECFM=N as suggested by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4"&gt;@ChrisHemedinger&lt;/a&gt;&amp;nbsp;'s blog post.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename in1 "H:\folder1\file1.xls" recfm=N;
filename ou1 "H:\folder2\file1.xls" recfm=N;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or use RECFM=F and LRECL=512.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 May 2026 16:19:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-fcopy-failing-to-copy-xls-file-creates-corrupted-1KB-file/m-p/987078#M380030</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2026-05-01T16:19:36Z</dc:date>
    </item>
    <item>
      <title>Re: SAS fcopy failing to copy .xls file (creates corrupted 1KB file)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-fcopy-failing-to-copy-xls-file-creates-corrupted-1KB-file/m-p/987097#M380038</link>
      <description>&lt;P&gt;You also could try this code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%let in1=H:\folder1\file1.xls;
%let ou1=H:\folder2\file1.xls;

data _null_;
rc=rename("&amp;amp;in1","&amp;amp;ou1",'file');
run;
&lt;/PRE&gt;</description>
      <pubDate>Sat, 02 May 2026 02:39:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-fcopy-failing-to-copy-xls-file-creates-corrupted-1KB-file/m-p/987097#M380038</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2026-05-02T02:39:11Z</dc:date>
    </item>
    <item>
      <title>Re: SAS fcopy failing to copy .xls file (creates corrupted 1KB file)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-fcopy-failing-to-copy-xls-file-creates-corrupted-1KB-file/m-p/987115#M380041</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename in1 "H:\folder1\file1.xls" lrecl=1 recfm=N;
filename ou1 "H:\folder2\file1.xls" lrecl=1 recfm=N;

data _null_;
  rc = fcopy("in1", "ou1");
  if rc = 0 then put 'Copy successful';
            else put 'Copy failed';
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 02 May 2026 12:46:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-fcopy-failing-to-copy-xls-file-creates-corrupted-1KB-file/m-p/987115#M380041</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2026-05-02T12:46:01Z</dc:date>
    </item>
  </channel>
</rss>

