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.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.