0
votes

I am trying to delete an XLSX file on the unix server and getting error messages. Below is my code. How can I delete this file in SAS EG? I need code to do this. Below are the error messages that I am getting.

filename myfile "/server/department/users/id/test/POP_ID.xlsx";
data _null_;
rc=fdelete("myfile");
run;
filename myfileclear;




ERROR: Invalid logical name.
ERROR: Error in the FILENAME statement.
2
Good practice is to serve the file read-only through a web service download. That way you can replace it (delete/recreate) without worrying about file locks, as could happen if file opened by Excel from a network share.Richard

2 Answers

3
votes

I believe the error relates to your last filename statement, where the ref is longer than 8 chars and the clear runs into the filename. I suspect if you add a space it will be fine.

filename myfileclear;

Should be:

filename myfile clear;
0
votes

This worked for me. I deleted filename myfileclear;.

%let outdir=/server/department/users/id/test;
filename myfile "&outdir/POP_ID.xlsx";
data _null_;
rc=fdelete("myfile");
run;
proc export DATA=OUT1.POP_ID_5C
            OUTFILE= "&outdir/POP_ID.xlsx"
            DBMS=xlsx REPLACE ;
                        SHEET = "POP_ID";
proc export DATA=OUT1.REQ_1_4_04T1
            OUTFILE= "&outdir/POP_ID.xlsx"
            DBMS=xlsx REPLACE ;
                        SHEET = "REQ_1_4";