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!
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.