Hello,
I am attempting to use the following %sysexec statement to move a zip file from one location to another:
However, it does not appear to work. I do not receive an error, but nothing happens. Both folders are on the same server.
Any suggestions?
Thank you!
Run your command with a pipe, so you can fetch the system's responses:
filename move pipe "move '&outpath.&filein' '&archive' 2>&1";
data _null_;
infile move;
input;
put _infile_;
run;
Hi,
Assuming you have at least SAS 9.4M2, as an alternative, you can do it in pure data step.
/* paths */
%let outpath = %sysfunc(pathname(work))/a/;
%let archive = %sysfunc(pathname(work))/b/;
%let filein = abc.zip;
/* make file */
filename abc ZIP "&outpath.&filein" member="abc.txt";
data _null_;
file abc;
do i = 1 to 1e5;
put i;
end;
run;
/* move */
filename in "&outpath.&filein" recfm=f lrecl=1;
filename out "&archive.&filein" recfm=f lrecl=1;
data _null_;
rc = fcopy("in", "out");
put rc = ;
if rc = 0 then rc = fdelete("in");
put rc = ;
run;
filename in;
filename out;
All the best
Bart
Yes, you should just use the FCOPY function.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.