DATA Step, Macro, Functions and more

Calling SAS from VBScript - Setting Macro Variables

Reply
Frequent Contributor
Posts: 97

Calling SAS from VBScript - Setting Macro Variables

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
SAS Super FREQ
Posts: 8,740

Re: Calling SAS from VBScript - Setting Macro Variables

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
Regular Contributor
Posts: 241

Re: Calling SAS from VBScript - Setting Macro Variables

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.
Frequent Contributor
Posts: 97

Re: Calling SAS from VBScript - Setting Macro Variables

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
Ask a Question
Discussion stats
  • 3 replies
  • 356 views
  • 0 likes
  • 3 in conversation