Run a Stored Process as a VBA Macro
Note: Support for VBA macros is deprecated in ArcGIS 10 and will no longer be supported in later versions of ArcGIS. In addition, SAS no longer ships the SAS Bridge for ESRI type library file. To run a stored process as a VBA macro, you must create the SASBridge.tlb type library file.
If you want to run a stored process, but do not have a SAS metadata server available, then you can run an IOM direct interface stored process by using a VBA macro.
IOM direct interface stored processes differ from SAS stored processes in that they run on a workspace server and cannot return streaming output.
To access a stored process from ArcMap:
Install ArcGIS VBA Resources
If you have not already done so, install the ArcGIS VBA Resources package from your ArcGIS installation media.
Create the SASBridge.tlb Type Library
- If you have not already done so, create the SAS Bridge for ESRI type library by using the .NET Assembly Registration tool. Submit the following command from a command prompt:
regasm sasbridge.dll /tlb:sasbridge.tlb /codebase
Define a SAS program:
- In SAS, select File New Program from the menu bar.
- Write your program. You can encapsulate any SAS DATA step or macro code in a stored process.
- Save the program. By default, the file extension is .sas. If you use this default extension, then you do not need to specify it in your ArcMap VBA macro.
Define a VBA macro in ArcMap:
- Open the Visual Basic Editor in ArcMap.
- Select Tools References from the menubar of the Visual Basic Editor.
- Select the following libraries from the References
window:
- SAS Bridge for ESRI 3.5 Type Library
- SAS: Integrated Object Model (IOM) (SAS System 9.3) Type Library
- SAS WorkspaceManager 1.1 Type Library
- Select Insert Module from the menubar of the Visual Basic Editor.
- Type the macro code. See Sample VBA macro to run a stored process for a sample macro that prints a SAS data set as an HTML file.
Run the macro:
- Select Tools Macros from the Visual Basic Editor menubar (or, Tools Macros Macros from the ArcMap menubar).
- Select the macro you want to run.
- Click Run.