Hello,
I have been running a VBS script that starts SAS EG 5.1, dynamically creates a project and runs some SAS Code. However, I have been embedding the SAS code within the VBS script. I would like to have the VBS script include the SAS program from a file on disk rather than embedded within the VBS program.
I have been reading and using several examples from Chris Hemmedinger. However, I cannot find any examples of how to use a SAS program that is stored on disk (called from VBS script). Unfortunately I am a SAS guy and not a Microsoft guy!
Does anyone have any examples?
Thanks!
Why not use the %INCLUDE SAS statement to read your SAS program? It would be easy enough for your VB code to run a single SAS %INCLUDE statement to get your remaining code.
Why not use the %INCLUDE SAS statement to read your SAS program? It would be easy enough for your VB code to run a single SAS %INCLUDE statement to get your remaining code.
%INCLUDE is for reading a SAS program off of the SAS session's file system. I'm guessing that @mclegry wants to slurp in a program from the local machine where EG is running.
You would use the FileSystemObject in VBScript to read the content of a local file, and assign that to the sasCode.Text value for your SAS program in the EG object model. Something like this partial program...
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
Set file = fso.OpenTextFile("C:\programs\myprogram.sas", 1)
' add a new code object to the Project
Set sasProgram = Project.CodeCollection.Add
' set the results types, overriding Application defaults
sasProgram.UseApplicationOptions = False
sasProgram.GenListing = True
sasProgram.GenSasReport = False
' Set the server (by Name) and text for the code
sasProgram.Server = "SASApp"
' Create the SAS program to run
sasProgram.Text = file.ReadAll
' Run the code
sasProgram.Run
Thank you Chris! This is exactly what I was looking for. SASKiwi also had a good suggestion about using a %INCLUDE. I will try both of these suggestions!
Thank you!.....Excellent idea!
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.