<?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 File from WORK to Network drive in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Copy-File-from-WORK-to-Network-drive/m-p/857272#M338743</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292396"&gt;@David_Billa&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;Please see my initial post. Background of the problem is '&lt;SPAN&gt;I was asked to tweak the following code (see my initial post) and the idea is to create file in WORK folder first and then copy that file to the output folder. Because our client observed that the users are accessing the file from the output folder before it is fully being generated. In order to prevent this issue, we came up with the above said approach. Is it good?&lt;/SPAN&gt;'&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Copying the file should be faster than building originally. So that would reduce the amount of time where the file might be visible to be found but incomplete.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to reduce the time then use the move (or rename) command instead of the copy command.&amp;nbsp; Then the change is almost instantaneous as only the directory entry is being changed.&amp;nbsp; You will need to use operating system commands for this as I don't think SAS has provided an FRENAME() function to move/rename a file. On Unix the command is mv and Windows the command is rename.&amp;nbsp; So write the original file to the target directory but use a name that the users will not try to open. For example change the extension to something else.&amp;nbsp; SAS won't mind when it creates the file, but users will not try to open it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example (Windows system):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename original 'c:\downloads\test_bad.junk_file' ;
ods excel file=original;
proc print data=sashelp.class; run;
ods excel close;

data _null_;
  infile "rename ""c:\downloads\test_bad.junk_file"" ""test_good.xlsx"" 2&amp;gt;&amp;amp;1" pipe ;
  input;
  put _infile_;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;For Unix the mv command will take full paths for both names.&amp;nbsp; And on Unix the file can be in a different subdirectory as long that directory is on the same physical disk.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  infile "mv ""/usr/local/downloads/test_bad.junk_file"" ""/usr/local/downloads/test_good.xlsx"" 2&amp;gt;&amp;amp;1" pipe ;
  input;
  put _infile_;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 05 Feb 2023 18:40:11 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2023-02-05T18:40:11Z</dc:date>
    <item>
      <title>Copy File from WORK to Network drive</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Copy-File-from-WORK-to-Network-drive/m-p/857222#M338705</link>
      <description>&lt;P&gt;I was asked to tweak the following code and idea is to create file in WORK folder first and then copy that file to the output folder. Because our client observed that the users are accessing the file from the output folder before it is fully being generated. In order to prevent this issue, we came up with the above said approach. Is it good? If yes, may I request someone to confirm whether the below code conversion is correct?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Current Version:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%macro clc_report;
ods excel file="&amp;amp;output_location./report_&amp;amp;reportDate._&amp;amp;reportTime..xlsx";
proc report data=appdata.test1; options missing=0;
column therapy_type;
define therapy_type / group "Therapy Type";
run;
ods excel close;

proc export data=appdata.test2
  outfile="&amp;amp;output_location./details_report_&amp;amp;reportDate._&amp;amp;reportTime..xlsx"
   dbms=xlsx
replace;
   sheet=All_CLCs;
run;

%mend;
&lt;/PRE&gt;
&lt;P&gt;Proposed Version:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%let work_path=%sysfunc(pathname(WORK));
 %put &amp;amp;=work_path;
%macro clc_report;
ods excel file="&amp;amp;work_path./report_&amp;amp;reportDate._&amp;amp;reportTime..xlsx";
proc report data=appdata.test1; options missing=0;
column therapy_type;
run;

* Copy the Excel  Report file from &amp;amp;work_path to &amp;amp;report_path *;
* include fcopy messages in the log *;
  options msglevel=i; 

  filename _SRC "&amp;amp;work_path./report_&amp;amp;reportDate._&amp;amp;reportTime..xlsx" recfm=n;
  filename _DEST "%unquote(&amp;amp;report_path)/report_&amp;amp;reportDate._&amp;amp;reportTime..xlsx" recfm=n;

  data _null_;
    rc=fcopy('_SRC', '_DEST');
    if rc=0 then
    put "Successful copy to &amp;amp;report_path/report_&amp;amp;reportDate._&amp;amp;reportTime..xlsx !";
    else do;
    put "Copy to &amp;amp;report_path/report_&amp;amp;reportDate._&amp;amp;reportTime..xlsx failed!";
    end;
  run;

  %g_catchErr(
        abortOnError = 0,
        appExceptionText = File copy to &amp;amp;report_path/report_&amp;amp;reportDate._&amp;amp;reportTime..xlsx failed!
        )

    filename _SRC clear;
    filename _DEST clear;

ods excel close;

proc export data=appdata.test2
  outfile="&amp;amp;work_path./details_report_&amp;amp;reportDate._&amp;amp;reportTime..xlsx"
   dbms=xlsx
replace;
    sheet=All_CLCs;
run;

* Copy the Excel Details Report file from &amp;amp;work_path to &amp;amp;report_path *;
* include fcopy messages in the log *;
  options msglevel=i; 

  filename _SRC "&amp;amp;work_path./details_report_&amp;amp;reportDate._&amp;amp;reportTime..xlsx" recfm=n;
  filename _DEST "%unquote(&amp;amp;report_path)/details_report_&amp;amp;reportDate._&amp;amp;reportTime..xlsx" recfm=n;

  data _null_;
    rc=fcopy('_SRC', '_DEST');
    if rc=0 then
    put "Successful copy to &amp;amp;report_path/details_report_&amp;amp;reportDate._&amp;amp;reportTime..xlsx !";
    else do;
    put "Copy to details_report_&amp;amp;report_path/details_report_&amp;amp;reportDate._&amp;amp;reportTime..xlsx failed!";
    end;
  run;

  %g_catchErr(
        abortOnError = 0,
        appExceptionText = File copy to &amp;amp;report_path/details_report_&amp;amp;reportDate._&amp;amp;reportTime..xlsx failed!
        )
    filename _SRC clear;
    filename _DEST clear;

%mend;

&lt;/PRE&gt;</description>
      <pubDate>Sun, 05 Feb 2023 07:51:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Copy-File-from-WORK-to-Network-drive/m-p/857222#M338705</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2023-02-05T07:51:30Z</dc:date>
    </item>
    <item>
      <title>Re: Copy File from WORK to Network drive</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Copy-File-from-WORK-to-Network-drive/m-p/857223#M338706</link>
      <description>&lt;P&gt;If the target destination (which means: your SAS server &lt;EM&gt;and&lt;/EM&gt; the NAS)&amp;nbsp;runs on UNIX, you can remove the file even when it is in use (as you do not remove the file itself, but only the directory entry).&lt;/P&gt;
&lt;P&gt;Run the external command &lt;FONT face="courier new,courier"&gt;rm -f&lt;/FONT&gt; before copying the file.&lt;/P&gt;</description>
      <pubDate>Sun, 05 Feb 2023 08:03:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Copy-File-from-WORK-to-Network-drive/m-p/857223#M338706</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-02-05T08:03:06Z</dc:date>
    </item>
    <item>
      <title>Re: Copy File from WORK to Network drive</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Copy-File-from-WORK-to-Network-drive/m-p/857226#M338708</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;Thanks for your reply. Two questions.&lt;/P&gt;
&lt;P&gt;A) Whether my proposed solution is correct even though it is not efficient?&lt;/P&gt;
&lt;P&gt;B) I have not used UNIX command &lt;SPAN&gt;&amp;nbsp;in my SAS program yet. It would be nice if you show me how and where to place rm -f command from my program?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 05 Feb 2023 08:15:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Copy-File-from-WORK-to-Network-drive/m-p/857226#M338708</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2023-02-05T08:15:42Z</dc:date>
    </item>
    <item>
      <title>Re: Copy File from WORK to Network drive</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Copy-File-from-WORK-to-Network-drive/m-p/857228#M338709</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
infile pipe "rm -f &amp;amp;reportpath./report_&amp;amp;reportdate._&amp;amp;reporttime..xlsx 2&amp;gt;&amp;amp;1";
input;
put _infile_;
run;

ods excel file="&amp;amp;report_path./report_&amp;amp;reportDate._&amp;amp;reportTime..xlsx";

proc report data=appdata.test1; options missing=0;
column therapy_type;
run;

ods excel close;

data _null_;
infile pipe "rm -f &amp;amp;report_path./details_report_&amp;amp;reportDate._&amp;amp;reportTime..xlsx 2&amp;gt;&amp;amp;1";
input;
put _infile_;
run;

proc export
  data=appdata.test2
  outfile="&amp;amp;report_path./details_report_&amp;amp;reportDate._&amp;amp;reportTime..xlsx"
  dbms=xlsx
  replace
;
sheet=All_CLCs;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This will work around any locked files, but only when all involved systems have filesystems with separate inode tables. Windows can't do this, as it stores file metadata in the directory entries.&lt;/P&gt;</description>
      <pubDate>Sun, 05 Feb 2023 09:35:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Copy-File-from-WORK-to-Network-drive/m-p/857228#M338709</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-02-05T09:35:46Z</dc:date>
    </item>
    <item>
      <title>Re: Copy File from WORK to Network drive</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Copy-File-from-WORK-to-Network-drive/m-p/857229#M338710</link>
      <description>&lt;P&gt;What's the use of 2&amp;gt;&amp;amp;1 in your infile statement?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;On a separate note, whether my proposed solution will work for windows? Sorry to ask this question again.&lt;/P&gt;</description>
      <pubDate>Sun, 05 Feb 2023 09:43:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Copy-File-from-WORK-to-Network-drive/m-p/857229#M338710</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2023-02-05T09:43:57Z</dc:date>
    </item>
    <item>
      <title>Re: Copy File from WORK to Network drive</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Copy-File-from-WORK-to-Network-drive/m-p/857256#M338729</link>
      <description>&lt;P&gt;What's the use of 2&amp;gt;&amp;amp;1 in your infile statement?&amp;nbsp; On a separate note, whether my proposed solution will work for windows? Sorry to ask this question again.&lt;/P&gt;</description>
      <pubDate>Sun, 05 Feb 2023 15:55:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Copy-File-from-WORK-to-Network-drive/m-p/857256#M338729</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2023-02-05T15:55:28Z</dc:date>
    </item>
    <item>
      <title>Re: Copy File from WORK to Network drive</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Copy-File-from-WORK-to-Network-drive/m-p/857262#M338735</link>
      <description>&lt;P&gt;2&amp;gt;&amp;amp;1 will redirect the standard error output (file handle 2) to the standard output (file handle 1).&amp;nbsp; So both the normal output message and the error output messages will be streamed as the output of the PIPE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use FCOPY to copy files on Windows. So as long as the paths you have constructed work on the machine where the SAS code is running then your program should run.&amp;nbsp; Did you try it?&lt;/P&gt;</description>
      <pubDate>Sun, 05 Feb 2023 17:46:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Copy-File-from-WORK-to-Network-drive/m-p/857262#M338735</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-02-05T17:46:08Z</dc:date>
    </item>
    <item>
      <title>Re: Copy File from WORK to Network drive</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Copy-File-from-WORK-to-Network-drive/m-p/857263#M338736</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;Thank you for the explanation. I yet to try the proposed solution per my initial post. So using '&lt;STRONG&gt;rm -f&lt;/STRONG&gt;' is the only efficient solution for my problem? It looks that the SAS runs on UNIX in our platform.&lt;/P&gt;</description>
      <pubDate>Sun, 05 Feb 2023 17:52:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Copy-File-from-WORK-to-Network-drive/m-p/857263#M338736</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2023-02-05T17:52:45Z</dc:date>
    </item>
    <item>
      <title>Re: Copy File from WORK to Network drive</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Copy-File-from-WORK-to-Network-drive/m-p/857264#M338737</link>
      <description>&lt;P&gt;Note that XLSX files are BINARY files.&amp;nbsp; You need to add RECFM=N to your FILENAME statements.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename xx "%sysfunc(pathname(work))/test1.xlsx" recfm=n;
filename yy "c:\downloads\test2.xlsx" recfm=n;
ods excel file=xx ;
proc print data=sashelp.class; run;
ods excel close;
%let rc=%sysfunc(fcopy(xx,yy));
%put &amp;amp;=rc;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 05 Feb 2023 17:53:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Copy-File-from-WORK-to-Network-drive/m-p/857264#M338737</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-02-05T17:53:26Z</dc:date>
    </item>
    <item>
      <title>Re: Copy File from WORK to Network drive</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Copy-File-from-WORK-to-Network-drive/m-p/857266#M338738</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292396"&gt;@David_Billa&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;Thank you for the explanation. I yet to try the proposed solution per my initial post. So using '&lt;STRONG&gt;rm -f&lt;/STRONG&gt;' is the only efficient solution for my problem? It looks that the SAS runs on UNIX in our platform.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The command "rm -f" is to remove a file and force the removal.&amp;nbsp; Not sure why you would need to remove the file?&amp;nbsp; If you wrote it into the WORK directory it should be removed when your session ends.&amp;nbsp; &amp;nbsp;But anyway you can use the FDELETE() function to delete the file with SAS code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also not sure why you would need the -f option. You wrote the file you should be able to remove it.&amp;nbsp; Some sites do tricks like make aliases named rm that include an option force the shell to always prompt you to confirm when deleting a file.&amp;nbsp; You can avoid that by either using the full name of the command (instead of letting the shell "find" it for you). You can also add \ in front of the command and it will not match an alias.&lt;/P&gt;</description>
      <pubDate>Sun, 05 Feb 2023 17:58:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Copy-File-from-WORK-to-Network-drive/m-p/857266#M338738</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-02-05T17:58:44Z</dc:date>
    </item>
    <item>
      <title>Re: Copy File from WORK to Network drive</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Copy-File-from-WORK-to-Network-drive/m-p/857267#M338739</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;that's great. Is this the alternate solution when compared to&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;program which he posted before. So&amp;nbsp;&lt;STRONG&gt;recfm=n&lt;/STRONG&gt; is not required when I consider to use the Kurt's approach?&lt;/P&gt;</description>
      <pubDate>Sun, 05 Feb 2023 17:59:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Copy-File-from-WORK-to-Network-drive/m-p/857267#M338739</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2023-02-05T17:59:34Z</dc:date>
    </item>
    <item>
      <title>Re: Copy File from WORK to Network drive</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Copy-File-from-WORK-to-Network-drive/m-p/857269#M338740</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;Please see my initial post. Background of the problem is '&lt;SPAN&gt;I was asked to tweak the following code (see my initial post) and the idea is to create file in WORK folder first and then copy that file to the output folder. Because our client observed that the users are accessing the file from the output folder before it is fully being generated. In order to prevent this issue, we came up with the above said approach. Is it good?&lt;/SPAN&gt;'&lt;/P&gt;</description>
      <pubDate>Sun, 05 Feb 2023 18:03:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Copy-File-from-WORK-to-Network-drive/m-p/857269#M338740</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2023-02-05T18:03:02Z</dc:date>
    </item>
    <item>
      <title>Re: Copy File from WORK to Network drive</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Copy-File-from-WORK-to-Network-drive/m-p/857270#M338741</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292396"&gt;@David_Billa&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;that's great. Is this the alternate solution when compared to&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;program which he posted before. So&amp;nbsp;&lt;STRONG&gt;recfm=n&lt;/STRONG&gt; is not required when I consider to use the Kurt's approach?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;No sure what you mean. RECFM=N is needed if you want SAS to COPY the file for you using the FCOPY() function. Otherwise it will copy it as text and mangle it.&amp;nbsp; If you are asking the operating system to copy the file then you don't need to specify RECFM=N as SAS will make the file properly without it.&lt;/P&gt;</description>
      <pubDate>Sun, 05 Feb 2023 18:29:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Copy-File-from-WORK-to-Network-drive/m-p/857270#M338741</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-02-05T18:29:06Z</dc:date>
    </item>
    <item>
      <title>Re: Copy File from WORK to Network drive</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Copy-File-from-WORK-to-Network-drive/m-p/857272#M338743</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292396"&gt;@David_Billa&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;Please see my initial post. Background of the problem is '&lt;SPAN&gt;I was asked to tweak the following code (see my initial post) and the idea is to create file in WORK folder first and then copy that file to the output folder. Because our client observed that the users are accessing the file from the output folder before it is fully being generated. In order to prevent this issue, we came up with the above said approach. Is it good?&lt;/SPAN&gt;'&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Copying the file should be faster than building originally. So that would reduce the amount of time where the file might be visible to be found but incomplete.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to reduce the time then use the move (or rename) command instead of the copy command.&amp;nbsp; Then the change is almost instantaneous as only the directory entry is being changed.&amp;nbsp; You will need to use operating system commands for this as I don't think SAS has provided an FRENAME() function to move/rename a file. On Unix the command is mv and Windows the command is rename.&amp;nbsp; So write the original file to the target directory but use a name that the users will not try to open. For example change the extension to something else.&amp;nbsp; SAS won't mind when it creates the file, but users will not try to open it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example (Windows system):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename original 'c:\downloads\test_bad.junk_file' ;
ods excel file=original;
proc print data=sashelp.class; run;
ods excel close;

data _null_;
  infile "rename ""c:\downloads\test_bad.junk_file"" ""test_good.xlsx"" 2&amp;gt;&amp;amp;1" pipe ;
  input;
  put _infile_;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;For Unix the mv command will take full paths for both names.&amp;nbsp; And on Unix the file can be in a different subdirectory as long that directory is on the same physical disk.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  infile "mv ""/usr/local/downloads/test_bad.junk_file"" ""/usr/local/downloads/test_good.xlsx"" 2&amp;gt;&amp;amp;1" pipe ;
  input;
  put _infile_;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 05 Feb 2023 18:40:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Copy-File-from-WORK-to-Network-drive/m-p/857272#M338743</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-02-05T18:40:11Z</dc:date>
    </item>
    <item>
      <title>Re: Copy File from WORK to Network drive</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Copy-File-from-WORK-to-Network-drive/m-p/857274#M338745</link>
      <description>This option sounds good. How to rename the .jung_file to .xlsx while in&lt;BR /&gt;proc export?&lt;BR /&gt;&lt;BR /&gt;Because our programs are using both ODS EXCEL and proc export to generate&lt;BR /&gt;output.xlsx files.&lt;BR /&gt;</description>
      <pubDate>Sun, 05 Feb 2023 18:45:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Copy-File-from-WORK-to-Network-drive/m-p/857274#M338745</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2023-02-05T18:45:58Z</dc:date>
    </item>
    <item>
      <title>Re: Copy File from WORK to Network drive</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Copy-File-from-WORK-to-Network-drive/m-p/857278#M338749</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292396"&gt;@David_Billa&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;This option sounds good. How to rename the .jung_file to .xlsx while in&lt;BR /&gt;proc export?&lt;BR /&gt;&lt;BR /&gt;Because our programs are using both ODS EXCEL and proc export to generate&lt;BR /&gt;output.xlsx files.&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;?? To change the name you use to create the file you just have to change the name you use in the code that creates the file.&lt;/P&gt;</description>
      <pubDate>Sun, 05 Feb 2023 19:15:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Copy-File-from-WORK-to-Network-drive/m-p/857278#M338749</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-02-05T19:15:24Z</dc:date>
    </item>
    <item>
      <title>Re: Copy File from WORK to Network drive</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Copy-File-from-WORK-to-Network-drive/m-p/857283#M338752</link>
      <description>&lt;P&gt;2&amp;gt;&amp;amp;1 has already been explained.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your code looks good, but it can only report that the file could not be replaced. That's the best you can get on Windows.&lt;/P&gt;</description>
      <pubDate>Sun, 05 Feb 2023 21:58:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Copy-File-from-WORK-to-Network-drive/m-p/857283#M338752</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-02-05T21:58:35Z</dc:date>
    </item>
    <item>
      <title>Re: Copy File from WORK to Network drive</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Copy-File-from-WORK-to-Network-drive/m-p/857303#M338758</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;Here are we copying the file from the xx folder to yy folder?&lt;/P&gt;</description>
      <pubDate>Mon, 06 Feb 2023 05:51:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Copy-File-from-WORK-to-Network-drive/m-p/857303#M338758</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2023-02-06T05:51:47Z</dc:date>
    </item>
    <item>
      <title>Re: Copy File from WORK to Network drive</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Copy-File-from-WORK-to-Network-drive/m-p/857313#M338766</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;Why two double quotes for every single folder in infile statement?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;""c:\downloads\test_bad.junk_file""&lt;/PRE&gt;</description>
      <pubDate>Mon, 06 Feb 2023 06:58:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Copy-File-from-WORK-to-Network-drive/m-p/857313#M338766</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2023-02-06T06:58:26Z</dc:date>
    </item>
  </channel>
</rss>

