BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mclegry
Fluorite | Level 6

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!

1 ACCEPTED SOLUTION

Accepted Solutions
SASKiwi
PROC Star

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.

View solution in original post

4 REPLIES 4
SASKiwi
PROC Star

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.

ChrisHemedinger
Community Manager

%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
SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!
mclegry
Fluorite | Level 6

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!

mclegry
Fluorite | Level 6

Thank you!.....Excellent idea!

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 3267 views
  • 2 likes
  • 3 in conversation