BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
eferencik
Fluorite | Level 6

I am trying to use SAS to copy an existing excel workbook (a template) and save it with a new name in a different folder (once updated with current data).  I have tried both steps below, but I cannot get either to work.  It seems like it should be simple to do, the only difference between the 2 workbooks would be the file name and location.

 

First tried:

options noxwait;

data _null_;

rc= system("copy S:\sas\Regular Reports\Vacancy Template.xlsx S:\oim\Regular Reports\Vacancy Report &sysdate..xlsx");

 

put rc=;

run;

 

Then I tried:

options noxwait;

data _null_;

oldname="S:\sas\Regular Reports\Vacancy Template.xlsx";

newname="S:\oim\Regular Reports\Vacancy Report &sysdate..xlsx";

rc= system(quote(catx(' ','copy',quote(trim(oldname)),quote(trim(newname)))));

put rc=;

run;

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

If you're using SAS 9.4 try FCOPY instead.

 


@eferencik wrote:

I am trying to use SAS to copy an existing excel workbook (a template) and save it with a new name in a different folder (once updated with current data).  I have tried both steps below, but I cannot get either to work.  It seems like it should be simple to do, the only difference between the 2 workbooks would be the file name and location.

 

First tried:

options noxwait;

data _null_;

rc= system("copy S:\sas\Regular Reports\Vacancy Template.xlsx S:\oim\Regular Reports\Vacancy Report &sysdate..xlsx");

 

put rc=;

run;

 

Then I tried:

options noxwait;

data _null_;

oldname="S:\sas\Regular Reports\Vacancy Template.xlsx";

newname="S:\oim\Regular Reports\Vacancy Report &sysdate..xlsx";

rc= system(quote(catx(' ','copy',quote(trim(oldname)),quote(trim(newname)))));

put rc=;

run;


 

View solution in original post

2 REPLIES 2
Reeza
Super User

If you're using SAS 9.4 try FCOPY instead.

 


@eferencik wrote:

I am trying to use SAS to copy an existing excel workbook (a template) and save it with a new name in a different folder (once updated with current data).  I have tried both steps below, but I cannot get either to work.  It seems like it should be simple to do, the only difference between the 2 workbooks would be the file name and location.

 

First tried:

options noxwait;

data _null_;

rc= system("copy S:\sas\Regular Reports\Vacancy Template.xlsx S:\oim\Regular Reports\Vacancy Report &sysdate..xlsx");

 

put rc=;

run;

 

Then I tried:

options noxwait;

data _null_;

oldname="S:\sas\Regular Reports\Vacancy Template.xlsx";

newname="S:\oim\Regular Reports\Vacancy Report &sysdate..xlsx";

rc= system(quote(catx(' ','copy',quote(trim(oldname)),quote(trim(newname)))));

put rc=;

run;


 

eferencik
Fluorite | Level 6

Thank you.  I searched FCOPY, found this and it works.

 

filename src "path-to-src" recfm=n;
filename dst "path-to-dst" recfm=n;
%let rc = %sysfunc(FCOPY(src,dst));
%put %sysfunc(SYSMSG());

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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
  • 2 replies
  • 5882 views
  • 2 likes
  • 2 in conversation