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
It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
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!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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