BookmarkSubscribeRSS Feed
camfarrell25
Quartz | Level 8

Hello, 

 

Been trying to replace/delete a sheet in excel (2013 - xslx) and export a dataset to the same workbook, although I seem to be hitting road blocks when it comes to directly modiying the excel spreadsheet. 

 

I've managed to set the libname: 

libname xls xlsx "(Excel FilePath.xlsx)";

but I'm not able to modify the workbook directly from SAS. 

 

I've seen some talk about using DDE but if there's a simple solution out there I would appreciate it. 

 

Any ideas??

 

Thanks!

 

CF 

3 REPLIES 3
Ksharp
Super User
Drop it firstly, before export it.


libname xls xlsx "(Excel FilePath.xlsx)";

proc sql;
drop table xls.have;

create table xls.have as 
select * from have;
quit;

SASKiwi
PROC Star

In addition to @Ksharp's method, I use PROC DATASETS to delete a sheet then add it again:

 

proc datasets library = xls;
  delete MySheet;
  run;
  copy in = WORK out = xls;
  select MySheet;
  run;
quit;
camfarrell25
Quartz | Level 8

When using that code, I get the following error message: 

ERROR: XLS.DATA.DATA cannot be deleted because files cannot be deleted from the XLS library.

 

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
  • 3 replies
  • 1191 views
  • 1 like
  • 3 in conversation