BookmarkSubscribeRSS Feed
hari1109
Fluorite | Level 6

Hi all,

I have a sheet in an excel work book and i would like to add another sheet as sheet 2 to the existing workbook at some point of time later (may be a month after) and in such a way i will be adding sheets generated using Proc report to the existing workbook. Is there any way to achieve it. Here i don't have a specific number of sheets in hand to write them off to the single workbook, i will be running my code to generate (using ODS TAGSETS.msoffice2k ) a new sheet every time and i have to add this new sheet to the existing workbook which may or may not be having sheets in it.

Thank you all.

4 REPLIES 4
hari1109
Fluorite | Level 6

Hi ART,

I have gone through those and are helpful but my issue is different , here i have to add an excel sheet every month and i have to put that sheet in the exisitng excel file. I have an excelfile with one sheet from the previous month and now i would like to add another sheet as sheet 2 to the existing excel workbook. In the same way i will be adding sheets as (sheet 3 ,sheet 4,...,sheet12 )to the existing excel workbook month after month. one way i am trying to do is to direct all the data sets to a location and then using proc datasets procedure to copy all the datasets from the pervious and current month to the work library and then using ods tagsets to create mutiple sheets in single excel work book.

Thank you.

SASKiwi
PROC Star

Using the ODS tagsets approach to building an Excel workbook requires that you create the workbook from scratch each time. You cannot add to an existing workbook. This is because ODS is not creating a native Excel wookbook but is creating an XML or HTML file that Excel knows how to interpret as a spreadsheet/workbook.

There are three choices I can think of:

1) Keep all of  the monthly datasets you need to create a complete workbook and use the ODS approach to create it completely from scatch each time.

2) PROC EXPORT can add a sheet to an existing workbook using the SHEET statement. Creates a native Excel workbook.

3) Use the LIBNAME EXCEL engine to do the same as 2).

Each of these choices has advantages and disadvantages. You will need to decide what suits you best. 

Ksharp
Super User

Add one more thing into SASKiwi.

ODS msoffice2K can also add a new sheet into a existing xls file. But that is not pure xls file.

Ksharp

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!

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
  • 923 views
  • 0 likes
  • 4 in conversation