Desktop productivity for business analysts and programmers

SAS EG Scripting (VBS) - Command to include a SAS PGM from disk

Accepted Solution Solved
Reply
New Contributor
Posts: 3
Accepted Solution

SAS EG Scripting (VBS) - Command to include a SAS PGM from disk

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!


Accepted Solutions
Solution
‎06-09-2016 10:30 AM
Respected Advisor
Posts: 3,063

Re: SAS EG Scripting (VBS) - Command to include a SAS PGM from disk

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


All Replies
Solution
‎06-09-2016 10:30 AM
Respected Advisor
Posts: 3,063

Re: SAS EG Scripting (VBS) - Command to include a SAS PGM from disk

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.

Community Manager
Posts: 2,693

Re: SAS EG Scripting (VBS) - Command to include a SAS PGM from disk

%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
New Contributor
Posts: 3

Re: SAS EG Scripting (VBS) - Command to include a SAS PGM from disk

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!

New Contributor
Posts: 3

Re: SAS EG Scripting (VBS) - Command to include a SAS PGM from disk

Thank you!.....Excellent idea!

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

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