Microsoft Integration with SAS

Using SAS with Microsoft Azure and Microsoft applications
BookmarkSubscribeRSS Feed
JRoman
Obsidian | Level 7

Greetings,

 

I'm wondering whether it is possible to leverage the SAS Add-in for Excel to run "raw" SAS code directly from VBA?  For example, I would like to have a VBA macro like the following (which references a hypothetical SubmitCode method):

 

Public Sub foo()
    Dim sas As SASExcelAddIn
    Set sas = Application.COMAddIns.Item("SAS.ExcelAddIn").Object
    sas.SubmitCode "%let foo=bar;"
End Sub

I'm not finding any method within the AMO documentation that would perform the role of that hypothetical SubmitCode method.

 

I'm aware that running code in this way is doable using the SAS OLE automation object (http://support.sas.com/documentation/cdl/en/hostwin/69955/HTML/default/viewer.htm#n11qaawfl1x9d6n1p3...), but I would prefer to stick with AMO since I already have other code using AMO and would like to have the same SAS workspace "behind the scenes", in order to have the same work library throughout the process.

 

Thanks for any help,

 

Jake

 

2 REPLIES 2
tomrvincent
Rhodochrosite | Level 12
you could pass the SAS code to a stored process and run it that way.
KatS_SAS
SAS Employee

 

There is no method to run the code directly in the VBA.

However, if you have already defined the SAS Program, executed it in the SAS Add-in and you have results in the workbook,  you could save the workbook, and use the Refresh method to refresh the workbook or a sheet in the workbook that contains the location of the code results. 

 

However, the first suggestion of placing your code in a stored process and executing the store process from the VBA would be a good solution to this question.

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

Discussion stats
  • 2 replies
  • 2337 views
  • 0 likes
  • 3 in conversation