BookmarkSubscribeRSS Feed
Mike_Davis
Fluorite | Level 6


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;

4 REPLIES 4
Linlin
Lapis Lazuli | Level 10

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;

Mike_Davis
Fluorite | Level 6

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

Reeza
Super User

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.

Mike_Davis
Fluorite | Level 6

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 4 replies
  • 848 views
  • 6 likes
  • 3 in conversation