Help using Base SAS procedures

Problem of this export

Reply
Regular Contributor
Posts: 222

Problem of this export


Hello everyone,

I have a problem to update an exist excel file,I attached an excel file and use the SAS code below to update this file.

I have get a result not as my expected,because the old sheet a didn't replace by sashelp.class but create a new sheet named a1.

Please help

Thanks!

Mike

PROC EXPORT DATA=sashelp.class

OUTFILE = "C:\Temp\test8.xls"

DBMS = /*EXCEL2002*/excel REPLACE;

SHEET = "a";

RUN;

Super Contributor
Posts: 1,636

Re: Problem of this export

Mike,

I don't have any problem to run your code and replace the old same named file.

you can try the modified code:

libname myfile "C:\Temp\test8.xls";

proc sql;

  drop table myfile."a$"n;

quit;

libname myfile clear;

PROC EXPORT DATA=sashelp.class

OUTFILE = "C:\Temp\test8.xls"

DBMS = excel REPLACE;

SHEET = "a";

RUN;

Regular Contributor
Posts: 222

Re: Problem of this export

Hi linlin,

The problem still happen,

when I followed your method, firstly the drop table statement ONLY remove the content of sheet a  to an empty sheet(didn't delete the sheet but just replace it with an empty sheet)
then still create a new sheet named a1 using sashelp.clas.

Thank you

Mike

Super User
Posts: 17,963

Re: Problem of this export

http://support.sas.com/kb/20/923.html

If you scroll to the bottom of the the communities, in very small fine print you'll see how to open a track with tech support.

Regular Contributor
Posts: 222

Re: Problem of this export

FILENAME MyFile "C:\temp\aa\cc\test8.xls"  ;
  DATA _NULL_ ;
    rc = FDELETE('MyFile') ;
  RUN ;

FILENAME MyFile CLEAR ;


PROC EXPORT DATA=sashelp.class

OUTFILE = "C:\Temp\aa\cc\test8.xls"

DBMS = excel2002 REPLACE;

SHEET = "a";

RUN;

this will delete all sheet including b,c,but work for a

Ask a Question
Discussion stats
  • 4 replies
  • 220 views
  • 6 likes
  • 3 in conversation