Hello Experts,
I would like to copy the files (SAS EG 8.3) :
option noxwait;
x 'cp C:\Users\XX\Desktop\Document\Lettre.pdf,
C:\Users\XX\Desktop\Documents_2024\Lettre.pdf');
But the file is not copied and I don't have an error message.
Thank you for your help.
Finally I used this function :
filename src "\\XXX \&PDF." recfm=n;
filename dst "\\XXX \&PDF." recfm=n;
%let rc = %sysfunc(FCOPY(src,dst));
%put %sysfunc(SYSMSG());
Things to check/do:
- Is sas running local or on a server? If it is running on a server, you can't copy local files.
- Is xcmd enabled?
- Change noxwait to xwait.
- Post the log.
Also, the name of the DOS command is copy, not cp. (And better remove the unbalanced parenthesis at the end. The comma is redundant.)
Whenever you need to run an external command, use the PIPE method:
filename xcom pipe "copy C:\Users\XX\Desktop\Document\Lettre.pdf C:\Users\XX\Desktop\Documents_2024\Lettre.pdf 2>&1";
data _null_;
infile xcom;
input;
put _infile_;
run;
This way, all messages returned from the command end up in the SAS log for inspection.
Finally I used this function :
filename src "\\XXX \&PDF." recfm=n;
filename dst "\\XXX \&PDF." recfm=n;
%let rc = %sysfunc(FCOPY(src,dst));
%put %sysfunc(SYSMSG());
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.