BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi friends,
I have schedule a SAS EG project . It created a EGScript.vbs file for me to run the project.
I want to know that how can i pass a parameter (eg. say a path of a input file which will be required somewhere in project code). I need to give this EGScript.vbs file to a guy who just need to change the path as per his requirement.
can someone help.
Thank You
17 REPLIES 17
deleted_user
Not applicable
hey ...if any body knows..... then plssssssss let me know...
tell me if there is some other way of doing it.... Message was edited by: Avi
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
When launching SAS, it is possible to pass a SYSPARM= parameter -- I suggest you explore how you can introduce this parameter into your vbs script as a command invocation parameter, then your SAS program can reference either the automatic macro variable named &SYSPARM, or you can retrieve the SYSPARM= character string using the SYSPARM() function.

The SAS DOC has information about SYSPARM.

Scott Barry
SBBWorks, Inc.
RichardH_sas
SAS Employee
Hi Avi,

I haven't done much with scheduling, but my guess is you're probably going to need to use a %LET statement to assign the path value. Anyone with better ideas please jump in!

So, if the parameter name is PATH1, I would create a Code Node at the top of your project with the code:

%LET path1=c:\whatever;

The person you're giving the project to will have to modify this code by hand to the appropriate path. Verify in the code/task that's using the path that there are double quotes to get the macro variable to resolve correctly.

RIGHT: "&path1\textfile.dat"
WRONG: '&path1\textfile.dat'

To be on the safe side, once you have the %LET in the project I'd then delete the parameter from the parameters manager. My guess is that EG would just sit there waiting for the user to type the parameter value if one is still in the project, but again, haven't tried this. Before you delete the parameter from the Parameters Manager, make sure you have a backup of the project in case my instructions are totally off-base!!

Hope this helps.
deleted_user
Not applicable
Hi
Thank you for the replies.
I tried giving some code in the EGscript.vbs like

project.run
project.submit("%let Mpath =%str(D:\SAS\InputFiles);")

This statement creates a Macro variable Mpath which can be resovled any where in project. this macro may be SYSparam also. but
which i hoped it will run as the first code in the project. But it not seems to be working. this code never runs ..... i checked logs
see the guy to which has nothing to do with sas ...My project creates few report based on a input file. the problem is the path to input file cannot be fixed... i have to give the only vbs script to him , and running the script runs the project on server .. and stores the o/p in a folder. so he needs to only modify the path when required in vbs script.
RichardH_sas
SAS Employee
Avi,

Are you using the path to point to raw data files (aka flat files), or SAS data sets, or something else entirely? I've got some ideas but wanted to ask that up front.
deleted_user
Not applicable
ya , i am using the path to point a rawdata file which is a CSV file.
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
The presumption here is that you need the variable data in your SAS environment. So, you need to determine how/where SAS is being invoked and introduce a SAS run-time CONFIG parameter override, either using SYSPARM= or you can use the IS= (short for INITSTMT= ) where you can supply directly your %LET statement. If you choose SYSPARM, then you can access the string using the SAS automatic variable &SYSPARM, or by using the SAS function SYSPARM() to assign a DATA step variable, as needed, in your application program.

Scott Barry
SBBWorks, Inc.
RichardH_sas
SAS Employee
I think you may be trying to do too much in the VB script and not enough in the project itself. I'm looking at a sample VB script that EG generated for scheduling, and I don't see anything in there that would allow you to set a value for a path. The relevant VB code seems to be:

' Start up Enterprise Guide using the project name
'----
Dim prjName
Dim prjObject

prjName = "C:\workshop\winsas\egqr4\DemoData\Demo.egp" 'Project Name

Set app = CreateObject("SASEGObjectModel.Application.4")
If Checkerror("CreateObject") = True Then
Exit Sub
End If

'-----
' open the project
'-----
Set prjObject = app.Open(prjName,"")
If Checkerror("app.Open") = True Then
Exit Sub
End If

You could explore whether using SYSPARM would allow you to supply the path to EG, as Scott suggests. I don't have much experience with that, but know SYSPARM is designed for situations like this.

Me personally, I would modify the part of the project that's reading the CSV file. Take the code generated by the import data task, copy it, and paste it into a new code node. Add a %let at the top of that code to store the path. Reference that macro variable on the infile statement (as previously posted). Lastly, get rid of the original import data task and any stuff in the parameters manager since the code node is going to handle that part. The end user will have to change the code in the project to meet their needs -- so you'll need to share the project AND the VB script. This may be what you were hoping to avoid... but this is the way I know how to do it. If you get desperate, remember you can say File > Export > Export All Code. This has it's own problems, but it's a good technique to know about.

So, hope you can get this working! I'm sorry I can't be more help on the VB stuff; I get lost once I start venturing outside SAS. 🙂
ChrisHemedinger
Community Manager
The EG automation model allows you to access and set values for project parameters -- those parameters that you've defined with the Tools->Parameter Manager.

Here is an example VB script that works with parameters that you've defined in your project.

[pre]
Option Explicit
Dim app
Dim prjName
Dim prjObject
Dim parmList
Dim parm

prjName = "C:\temp\autowithparams.egp" 'Project Name

' start the app and open the project
Set app = CreateObject("SASEGObjectModel.Application.4")
Set prjObject = app.Open(prjName,"")

' discover the parameters
Set parmList = prjObject.Parameters
Wscript.Echo "Project has " & parmList.Count & " parameters."

' work with the first parameter
Set parm = parmList.Item(0)
WScript.Echo parm.Name & " parameter has default value of " & parm.DefaultValue
parm.Value = "M"

WScript.Echo parm.Name & " parameter has been set to value of " & parm.Value

' run the project
prjObject.Run

WScript.Echo parm.Name & " parameter has been set after Run to value of " & parm.Value

prjObject.Close
app.Quit
[/pre]

Chris
Learn from the Experts! Check out the huge catalog of free sessions in the Ask the Expert webinar series.
deleted_user
Not applicable
hey Chris,

I will definitely try this.
I had previously tried written below,but some thing went wrong.

prjObject.code mycode = prjObject.codeCollection.add;
mycode = "%Let mypath=%str(D:\SAS\INputfiles)"
mycode.run

i will let you know the results ..thanks.

regards
Avi
deleted_user
Not applicable
Hi chris ...

Thank you very much . The solution you gave was perfect. It worked fine.

Avi
DF
Fluorite | Level 6 DF
Fluorite | Level 6
@Chris,

The code example you provided allows for a parameter's value to be set using its numerical index, but is there a method that allows it to be set by name?

The only method I've found, which seems a strange approach, is to parse the list of parameters until I match the required name and then set the value. This doesn't seem like the best approach, but I've been unable to find any other way to access a specific parameter.
ChrisHemedinger
Community Manager
DF,

No, I don't think there is a better approach right now when using VBScript to automate it. I admit it's a bit klunky...

Chris
Learn from the Experts! Check out the huge catalog of free sessions in the Ask the Expert webinar series.
DF
Fluorite | Level 6 DF
Fluorite | Level 6
Thanks for clarifying that Chris - I can stop looking now!

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 17 replies
  • 11681 views
  • 0 likes
  • 6 in conversation