I am using SAS Enterprise Guide 7.12 HF3 (7.100.2.3444) (64-bit)
I have a SAS file called CalculateLoad.egp which just imports some CSV files, grabs some data from a Windows SQL Server, does a few calculations and spits out a CSV file.
I wanted to run CalculateLoad.egp several times via automation. I wanted to use Excel VBA to let the user run the CalculateLoad.egp many many times.
I have been following this document (http://support.sas.com/resources/papers/proceedings12/298-2012.pdf) that tells me how to use Excel VBA to automate a SAS Program.
For reference, the relevant VBA code is below (its on Page 6 of the document):
Option Explicit ' Forces us to declare all variables
Dim Application ' Application
Dim Project ' Project object
Dim sasProgram ' Code object (SAS program)
Dim n ' counter
Set Application = CreateObject("SASEGObjectModel.Application.4.3")
' Set to your metadata profile name, or "Null Provider" for just Local server
Application.SetActiveProfile("My Server")
' Create a new Project
Set Project = Application.New ' add a new code object to the Project
Set sasProgram = Project.CodeCollection.Add
The code I am trying to write is as follows:
Public Application
Public Project
Public sasProgram
Sub Example2()
Set Application = CreateObject("SASEGObjectModel.Application.7.1")
Set Project = Application.New ' <<<<------- ERROR OCCURING HERE
End sub
The error message I am getting is:
Run-time error '-2146233036 (80131534)': The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception.
I also get this error if I try: Set Project = Application.Open("c:\myprojects\project.egp", "")
I would appreciate some guidance.... Thanks....
Some additional background information (just in case it is relevant):
When SAS was first installed I couldn't even execute: Set Application = CreateObject("SASEGObjectModel.Application.7.1").
I got the following error message from VBA:
Run-time error '429': ActiveX component can't create object
From Googling, I ran the following from command prompt:
RegASM.exe /tlb:SASEGScripting.tlb /codebase “C:\Program Files\SASHome94M3\SASEnterpriseGuide\7.1\SASEGScripting.dll
and then
RegTypeLib.exe “C:\Program Files\SASHome94M3\SASEnterpriseGuide\7.1\SASEGScripting.tlb”
So now VBA happliy executes Set Application = CreateObject("SASEGObjectModel.Application.7.1")
But it doesn't like Set Project = Application.New or Set Project = Application.Open("c:\myprojects\project.egp", "")
Would appreciate it if someone knows how to fix it. Thanks.
I'm afraid that the exception is caused by using 32-bit Excel to automate a 64-bit version of SAS Enterprise Guide. I think that the Git integration with EG (LibGit2Sharp) is specific to the bit architecture, so you have to drive this from a 64-bit process or install a 32-bit version of SAS Enterprise Guide. Someone like @CaseySmith might be able to confirm.
I'm afraid that the exception is caused by using 32-bit Excel to automate a 64-bit version of SAS Enterprise Guide. I think that the Git integration with EG (LibGit2Sharp) is specific to the bit architecture, so you have to drive this from a 64-bit process or install a 32-bit version of SAS Enterprise Guide. Someone like @CaseySmith might be able to confirm.
Chris is correct. The libgit2 library (git2-e0902fb.dll) (which EG accesses via LibGit2Sharp) is specific to the bit architecture.
If you disable EG's Program History feature (uncheck "Enable program history" in Tools->Options->Program History), you should get further, since the library is not immediately loaded in that case. However, if you do any operations that result in EG attempting to use the library, you'll see the exception again. (For example, I noticed simply opening a saved project causes the library to get loaded even if the Program History feature is off.) Otherwise, I second Chris' suggested workarounds.
Register today and join us virtually on June 16!
sasglobalforum.com | #SASGF
View now: on-demand content for SAS users
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.
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.