Note that XLSX files are BINARY files. You need to add RECFM=N to your FILENAME statements.
Example:
filename xx "%sysfunc(pathname(work))/test1.xlsx" recfm=n;
filename yy "c:\downloads\test2.xlsx" recfm=n;
ods excel file=xx ;
proc print data=sashelp.class; run;
ods excel close;
%let rc=%sysfunc(fcopy(xx,yy));
%put &=rc;
@Tom that's great. Is this the alternate solution when compared to @Kurt_Bremser program which he posted before. So recfm=n is not required when I consider to use the Kurt's approach?
@David_Billa wrote:
@Tom that's great. Is this the alternate solution when compared to @Kurt_Bremser program which he posted before. So recfm=n is not required when I consider to use the Kurt's approach?
No sure what you mean. RECFM=N is needed if you want SAS to COPY the file for you using the FCOPY() function. Otherwise it will copy it as text and mangle it. If you are asking the operating system to copy the file then you don't need to specify RECFM=N as SAS will make the file properly without it.
@Tom Here are we copying the file from the xx folder to yy folder?
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!
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.