BookmarkSubscribeRSS Feed
cbourne090
Calcite | Level 5

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
Kurt_Bremser
Super User

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;
yabwon
Onyx | Level 15

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



ChrisNZ
Tourmaline | Level 20

Yes, you should just use the FCOPY function.

SAS Innovate 2025: Call for Content

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!

Submit your idea!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 1398 views
  • 1 like
  • 4 in conversation