BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hello!

I've inherited a piece of VB6 legacy code and, what this particular piece of VB6 code does, is that it creates a "windowed" version of SAS(so, not the batch-mode SAS), runs a script(which takes about 2 hours to finish executing), after which, ideally, it should close the windowed SAS.

Here's the VB6 code snippet that I inherited:
"
Dim OleSAS As Object
Set OleSAS = CreateObject("SAS.Application")
OleSAS.Visible = True
OleSAS.Top
OleSAS.Command ("include '" + "X:\DATA\DAILYRUN.SAS")
OleSAS.Command ("submit")

pause 60 * 30 'wait 30 minutes, because SAS runs asynchronously

OleSAS.Quit
Set OleSAS = Nothing
"

The reason I am posting in here is that I have had co-workers(who know pure SAS very well), suggesting that I ask in here if there isn't a reliable way of getting SAS to recognize when the script it is running has completely finished, after which the statements that would close SAS would be called upon.

I guess my question is whether there is a property or statement that would allow me to replace the last 3 lines of the snippet code with something like this:
"
If OleSAS.ScriptExecutionFinished Then
OleSAS.Quit
Set OleSAS = Nothing
End If

Also, I hope I posted in the right forum, my reasoning was that a VB6/SAS issue is closer to MS Office than "ODS and Base Reporting", but, if I am wrong, I can move the thread to the "ODS" forum.

Thank you!
1 REPLY 1
Cynthia_sas
SAS Super FREQ
Hi:
You were right, this question doesn't belong in the ODS forum. But, you probably won't get many responses in this forum, either. Your best bet for help might be to search in the Tech Support site or look in the SAS Companion to the Windows Operating System for the chapter entitled, "Controlling the SAS System from Another Application Using OLE".

The documentation in the SAS Companion contains the OleSAS.Quit example you show in your code:
"This Visual Basic code ends the SAS session provided that there are no other OLE automation controllers making use of it.

OleSAS.Quit
Set OleSAS = Nothing "

Then there is other documentation on the QUIT method:
"If the automation controller that issues the Quit method is the only controller that is using that particular SAS session, then the SAS session ends. If at least one other automation process is still using the SAS session, then the session remains running.

If you do not use the Quit method at the end of your automation sequence and the Visible property for the SAS session is set to True, then the SAS session remains running and is available for user interaction. If the Visible property is not set to True, then the SAS session ends."

For a timely response to your question, your best bet is to contact Tech Support, as they have the VB expertise to help you.

cynthia

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

Discussion stats
  • 1 reply
  • 694 views
  • 0 likes
  • 2 in conversation