SAS Programming

DATA Step, Macro, Functions and more
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-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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