- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 10-21-2020 02:20 PM
(1935 views)
Hello,
I am attempting to use the following %sysexec statement to move a zip file from one location to another:
- %sysExec move "&outpath.&filein" "&archive";
- &outpath = the location of the zip file I am attempting to move.
- &filein = the name of the zip file that I am trying to move (i.e. myzipfile.zip).
- &archive = the location I would like to move the zip file to.
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!
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug
"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings
SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug
"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings
SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Yes, you should just use the FCOPY function.