Once instantiated , the SAS OLE automation object supports these methods as well as several properties:
'Command Method' on page 268
'QueryWindow Method' on page 269
'Quit Method' on page 269
'Submit Method' on page 270
'Top Method' on page 270
'Properties for Controlling a SAS Automation Object' on page 271
Invokes a command as if it was entered from the SAS command line
Command(' sas-command ')
By default, the active window receives the command. You can change which window receives the command by changing the CommandWindow property.
This Visual Basic code invokes a SAS session and opens the BUILD window:
Set OleSAS = CreateObject("SAS.Application") OleSAS.Command("build")
Queries whether a specified window exists within the SAS session
QueryWindow(' window- name ')
QueryWindow returns either True or False based on whether the specified window is open in the automated SAS session. If the window exists but is not visible, QueryWindow still returns True.
The window name that you specify must match the exact spelling of the window name in SAS. The window-name argument is not case sensitive.
This Visual Basic code gets an existing SAS session and checks whether the BUILD window is open. If the window is not open, this code invokes BUILD:
Dim OleSAS as Object Set OleSAS = GetObject(,"SAS.Application") If (Not OleSAS.QueryWindow("build")) Then OleSAS.Command("build") EndIf
Ends the SAS session
Quit
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.
Submits DATA step or procedure code for processing
Submit(' SAS-program-code ')
The string of text that you specify as SAS-program-code can contain multiple SAS statements separated by semicolons. The contents of the string are submitted to SAS for processing.
The following example references a data library and invokes a SAS/AF application:
Dim OleSAS as Object Set OleSAS = CreateObject("SAS.Application") OleSAS.Visible = True OleSAS.Submit("libname afapp 'f:\sas\afapp';") OleSAS.Command("af c=afapp.bigapp.main.frame")
Brings the SAS session to the foreground
Top
The Top method works only if the Visible property is set to True.
The following example invokes a SAS session, makes it a visible window, and then brings it to the foreground.
Dim OleSAS as Object Set OleSAS = CreateObject("SAS.Application") OleSAS.Visible = True OleSAS.Top
Specify various properties of the SAS automation object
Busy
indicates whether SAS is idle or working (for example, running a procedure, DATA step, and so on). This property is read only.
CommandWindow
sets the window (based on the window title) to receive commands you specify using the Command method. The name you specify must match the spelling of the window name exactly (though this property is not case sensitive). Once set, the window receives subsequent commands you specify with the Command method until CommandWindow is changed or set to Null (by specifying ""). If Null, which is the default, the currently active window receives the command. This property is read/write.
CommandWindowVisible
controls whether the window specified by the CommandWindow property is visible. If set to False, the window specified by the CommandWindow property is set to invisible. If the CommandWindow property is Null, this property has no effect. This property is read/write.
ConfirmExit
controls the behavior of how SAS exits. A value of 0 means that no confirmation box is displayed before SAS exits. A value of 1 means that a confirmation box is displayed before SAS exits. A value of 2 selects the default action, which is controlled by an alternative method that defines how SAS exits; for example, the Preferences dialog.
Height
sets the height, in pixels, of the SAS application window. This property is read/ write.
Parent
sets the name of the parent window that contains the SAS application window. If you change this value to another window, the SAS application window resizes to fit in the new frame. This property is read/write.
RC
returns the return code passed by a user function. You can set this property from within the SAS session by using the SETRC function. This property is read-only from the automation controller.
ResultString
returns a string passed by a user function. You can set this property from within the SAS session by using the SETRC function. This property is read-only from the automation controller.
Title
sets the main SAS window title. This property is read/write.
Visible
controls whether SAS is visible. This property is read/write.
Width
sets the width, in pixels, of the SAS application window. This property is read/ write.
X
sets the horizontal coordinate, in pixels, for the top left corner of the SAS application window. This property is read/write.
Y
sets the vertical coordinate, in pixels, for the top left corner of the SAS application window. This property is read/write.