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.
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.
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:
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.
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!!
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.
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.
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
prjName = "C:\workshop\winsas\egqr4\DemoData\Demo.egp" 'Project Name
Set app = CreateObject("SASEGObjectModel.Application.4")
If Checkerror("CreateObject") = True Then
' open the project
Set prjObject = app.Open(prjName,"")
If Checkerror("app.Open") = True Then
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.
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.