BookmarkSubscribeRSS Feed
cjohnson
Obsidian | Level 7
I have been learning to call SAS from VBScripts, but have had little luck finding resources for this. I have a script that opens as SAS project, runs two code files, Saves, and exits. I need to be able to set a macro variable from the script, but I have no idea how. Here is my script:

'Set ErrorHandler
On Error Resume Next

'Run Daily
ProjectName = "\\Nasvs1\Shared\4700Mac\Shared3\Actuarial\SAS\Projects\ISO.egp"
Files = Array("LIBRARIES", "PLCY")
Call Work(ProjectName, Files)

'Define Functions
Sub Work(ProjectName, Files)
Set App = CreateObject("SASEGObjectModel.Application.4")
Set Project = App.Open(ProjectName,"")
Set Container = Project.CodeCollection
For Each File In Files
For Each Object In Container
If Object.Name = File Then Object.Run
Next
Next
Project.Save
Project.Close
End Sub

'Reset Error Handler
On Error Goto 0


Here is the variable in the file PLCY that I would like to set:

%LET INFILE = "&ISODATA.G0024P1_D110415.TXT";


Any help would be greatly appreciated!

Chris
Christopher Johnson
www.codeitmagazine.com
3 REPLIES 3
Cynthia_sas
Diamond | Level 26
Since you are using SAS Enterprise Guide, you might want to post this question to the SAS Enterprise Guide forum. The folks who use VBScript with EG are mostly over there.

cynthia
chang_y_chung_hotmail_com
Obsidian | Level 7
One straight-forward way is: Read the PLCY file and insert or replace the %LET INFILE... line with something you want and then run the rest of the code.
cjohnson
Obsidian | Level 7
Thanks. That helps. Can you submit/run code in EG without inserting it into a code file?

For example, in SAS (not EG), you can do something like this:

Set objSAS = Wscript.CreateObject("SAS.Application.8")
objSAS.Submit("data test;a=1;output;proc print;run;")
Christopher Johnson
www.codeitmagazine.com

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

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 3 replies
  • 2008 views
  • 0 likes
  • 3 in conversation