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
SAS Super FREQ
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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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