BookmarkSubscribeRSS Feed
AllanN
Calcite | Level 5

Hi everybody, my first post here. First of all, sorry about my english.

I've question for you, specialists Smiley Wink.

I wanna make (now i started to make) a VBA application in Microsoft Excel to catch data from SAS and put it into a Worksheet. My question is, what's the best way to do this?

I'm thinking about using ADODB connections, and get data from a recordset. Im studying about how to do this in SAS, and learned about which library i have to make reference, and what object i have to use. But, in my case, the documentation don't help me to understand some questions. I have to create a workspace? How can i make sas run the code? (i dont wanna put it in a array or something part of vba code, the code is extensive)

If someone can give me a help about "do this way" or "no.. u're wrong use that"... i'll appreciate.

Thanks before any answer.

3 REPLIES 3
AllanN
Calcite | Level 5

Just for information, Here's My code, please welcome for any suggestion:

'Reference to Objects and Libraries

Dim Connect_ADO As New ADODB.Connection
Dim WorkSAS As SAS.Workspace
Dim WorkManager As New SASWorkspaceManager.WorkspaceManager
Dim DefineServer As New SASWorkspaceManager.ServerDef
Dim AddObj As New SASObjectManager.ObjectKeeper

'Create SAS WorkSpace

Public Sub Create_WorkSpace()
    Dim Inf As String
    DefineServer.Protocol = ProtocolBridge
    DefineServer.MachineDNSName = "myremoteserver.dns.com"
    DefineServer.Port = 8591
   
    Set WorkSAS = WorkManager.Workspaces.CreateWorkspaceByServer("SAS", VisibilityProcess, DefineServer, "mylogin", "mypass", Inf)
   
    'Run code from my machine, acessing server in network
    Dim SASproc As SAS.StoredProcessService
    Set SASproc = WorkSAS.LanguageService.StoredProcessService
    SASproc.Repository = "file:/networkpc/mycodes"
    SASproc.Execute "MyCode.sas", "argument=123"
   
End Sub

'Finish and Close SAS WorkSpace, This  code isn't working

Public Sub Finish_Workspace()

    WorkManager.Workspaces.RemoveWorkspaceByUUID WorkSAS.UniqueIdentifier
    WorkSAS.Close
    Set WorkSAS = Nothing

End Sub

AllanN
Calcite | Level 5

Just for cooperation, i have success doing  this using filename command and language services objects, if someone have interest, i post the code.

Raghs_Newbee
Calcite | Level 5

Hi Allan, Looks like you have done something interesting..in which I am trying to learn.

Can you please share the code of what you have done.

Thanks,

Raghuraman Ramesh    

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!

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