BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
vibeznstuff
Fluorite | Level 6

Hi there,

I'm trying to execute a stored process (doesn't take any parameters) from Excel VBA but it doesn't seem to be working. It works when I run it in SAS (simply creating a table that filters on a column, this is all for testing purposes) but when I run it in Excel it doesn't seem to execute (and it doesn't crash either). I'll run the macro but when I check the output dataset it remains unchanged as if the process didn't run. When I then run it in SAS it works as expected. I'll paste the structure of my code below if anyone might be able to spot any issues that I'm missing. Also, connecting to the workspace hasn't been an issue. I've been able to pull data fine and it even seems to be finding the procedure as well.

*************************************************************************************************

    Dim obSAS As SAS.Workspace

    Dim obWorkspaceManager As New SASWorkspaceManager.WorkspaceManager

    Dim obServerDef As New SASWorkspaceManager.ServerDef

    Dim xmlString As String

    obServerDef.Port = 8591

    obServerDef.Protocol = ProtocolBridge ' Multiple hostNames can be provided

                                          ' for failover; order is unreliable.

    obServerDef.MachineDNSName = "abc.domain.com"

    Set obSAS = obWorkspaceManager.Workspaces.CreateWorkspaceByServer("", VisibilityProcess, obServerDef, "user", "pwd", xmlString)

    Dim SASproc As SAS.StoredProcessService

    Set SASproc = obSAS.LanguageService.StoredProcessService

    SASproc.Repository = "file:/path"

    SASproc.Execute "testSP.sas", ""

*************************************************************************************************


Thanks for any help in advance. I'm pretty new to this.


Best,


Richard

1 ACCEPTED SOLUTION

Accepted Solutions
vibeznstuff
Fluorite | Level 6

Nevermind, I found what the error was after checking the log output (should have done so from the start). I was getting a "lock is not available" error because I had the dataset/proc open on the actual SAS session and I think it was creating a conflict with my call from Excel.

source: 8130 - "Lock is not available" error message appears when running multiple SASjobs with data files p...

View solution in original post

2 REPLIES 2
vibeznstuff
Fluorite | Level 6

Nevermind, I found what the error was after checking the log output (should have done so from the start). I was getting a "lock is not available" error because I had the dataset/proc open on the actual SAS session and I think it was creating a conflict with my call from Excel.

source: 8130 - "Lock is not available" error message appears when running multiple SASjobs with data files p...

LineMoon
Lapis Lazuli | Level 10

@vibeznstuff

Hello,

I am inerested by your subject.

Can we use  VBA and Excel to call a SAS stored processes, if we do not have a  SAS Add-In for Microsoft Office ?

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1928 views
  • 1 like
  • 2 in conversation