1.Drive the SAS session to open: Assume a command button was set up with a property name, Run SAS, and SAS.EXE is located at C:\Program Files\SAS\sas.exe. The code in the Visual Basic module will be: Private Sub Run_SAS_Click() Dim olesas As Object Set olesas = CreateObject("SAS.Application") olesas.Visible = True End Sub 2. Drive the SAS program to run: Once the SAS session is open, the program can be submitted from the session. This event can also be done with the GUI. Suppose we need to submit a SAS program, autoexec.sas (as all other SAS programs do in this paper), residing in C:\SAS\ directory , we just need to add one more line of the above VB script to the Visual Basic module as follows: Private Sub Run_sas_Click() Dim olesas As Object Set olesas = CreateObject("SAS.Application") olesas.Submit ("%inc 'C:\SAS\autoexec.SAS '; ") olesas.Visible = True End Sub 3. Drive SAS statements, DATA steps, or procedures to run: The Visual Basic script can submit SAS code to the SAS session. The following is an example of using the PRINT procedure to print a dataset located at C:\SAS. Private Sub Run_sas_Click() Dim olesas As Object Set olesas = CreateObject("SAS.Application") olesas.Submit("libname dm ‘C:\SAS’; proc print data=dm.demo; run;") olesas.Visible = True End Sub |
-- |
Sunday, August 4, 2013
SAS Through VBA
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment