BookmarkSubscribeRSS Feed
TracyH17
Calcite | Level 5

Hello,

 

I need to automate population of a an excel workbook. The spreadsheets have very specific formatting and layout requirements. I need to generate one workbook per study group, for a total of 44 study groups. Each workbook has two worksheets. The worksheets will need to contain formulas.

 

A colleague of mine recommended that I look into using the SAS Libname engine approach. I've also read a little about ODS using the Excel tagsets, and have read a little about DDE.  

 

This colleague sent me the following paper: http://www2.sas.com/proceedings/sugi31/024-31.pdf . On pages 3-4 of the paper, it states:

 

"The SAS libname engine does not have the capacity to...write a formula into a cell." and "Note that DDE may be used to create, delete, or rename spreadsheets, as well as to format worksheets and enter and delete formulas."

 

Questions:

(1) for those of you with experience using both the SAS libname and DDE approaches to populating formatted excel workbooks, can I combine these approaches so that I can use the latter to overcome the limitations of the former (specifically with regard to creating formulas)?

(2) are there other approaches I can use to populate excel workbooks that have very specific formatting and layout requirements? My colleague looked at the workbook templates and thought I'd have difficulty trying to use ODS to match the formatting/layout.

 

 

Thank you,

 

Tracy

 

 

3 REPLIES 3
Reeza
Super User

See this macro which should allow you more flexibility in exporting your data.

 

http://www.sascommunity.org/wiki/A_Poor/Rich_SAS_Users_Proc_Export

 

Otherwise DDE or executing an external VBS script is an option. You can use SAS to generate the VBS script if necessary.

TracyH17
Calcite | Level 5

I am not familiar with VB. Is there another way to populate formatted excel spreadsheets without having to use VB?

Reeza
Super User

Did you read the paper or try it?

You don't need to know VB for it. 

 

In my experience it's your best bet given your stated requirements. Otherwise DDE is your second choice.

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
  • 735 views
  • 0 likes
  • 2 in conversation