BookmarkSubscribeRSS Feed
nrabonik
Calcite | Level 5

Chris -

I am trying to pass a parameter from a vbs/wsf code into a SAS Project. I am using your approach but am not having success. (I am using EG 4.3, which points to a SAS Server running 9.2). In essence, while it looks like the vbs object gets the correct variable values set, (and even indicates that the default values for each parameter are correctly set and extracted), the parameter values do not seem to exist when the SAS project starts to execute. Sorry in advance for writing so much.

1. in my sas project, i have added three variables using the Prompt Manager window. They are filepath, lastmoddate, lastmodtime.

2. in my vbs code, i have

a)the code:

=========

' Declare SAS object/Variables

Dim oSASApp

Dim oSASProj

Dim oParmCollection

Dim oParm

dim sSasP ' Path to SAS code

dim sSasF ' Filename of SAS code

dim filepath

dim moddate

dim modtime

sSasF = "*****************\shell_of_ice.egp" 'Does not end w/.egp

  moddate = "09/09/9999"

  modtime = "09:09:09"

WScript.Echo moddate & " " & modtime

' start the sas app and open the project    

  Set oSASApp = CreateObject("SASEGObjectModel.Application.4.3")

WScript.Echo "sasapp setup"

  Set oSASProj = oSASApp.Open(sSasF,"")

WScript.Echo "I have setup sas proj."

         

  ' Discover parameters Within the opened SAS project which are already defined.

  Set oParmCollection = oSASProj.Parameters

 

  ' pass values to those parameters

  dim p

  for p = 0 to oParmCollection.Count - 1

    Set oParm = oParmCollection.Item(p)

    WScript.Echo oParm.Name & " parameter has default value of " & oParm.DefaultValue

    if oParm.Name = "lastmoddate" then

       oParm.Value = moddate

    elseIf oParm.Name = "lastmodtime" then

       oParm.Value = modtime

    else 'filepath

       oParm.Value = filepath

    end if

  next 'p

  ' run the project

msgbox "about to run project"

  oSASProj.Run

msgbox "ran project"

b)the output from vbs:

==================

I have setup sas proj.

filepath parameter has default value of **************\poweractivity_2011_12_22.csv

lastmoddate parameter has default value of 01/01/01

lastmodtime parameter has default value of 01:01:01

3. below is the log from the SAS project executing - please note, i have used %put statements at the beginning of my SAS Program and also at the end. I am getting the following errors:

16         %put &filepath;

WARNING: Apparent symbolic reference FILEPATH not resolved.

&filepath

17         %put &lastmoddate;

WARNING: Apparent symbolic reference LASTMODDATE not resolved.

&lastmoddate

18         %put &lastmodtime;

WARNING: Apparent symbolic reference LASTMODTIME not resolved.

&lastmodtime

Many thanks,

nrabonik
Calcite | Level 5

ok i resolved the issue!! and will leave the post up in case it will be of help to others.

while i already defined the different parameters, i did not attach them to a particular program in the project. to do this, right click the program in the Process Flow view, and select Properties, and then Prompts. Then, one by one, associate each prompt parameter to the desired program.

Steep learning curve, for sure.

RichardH_sas
SAS Employee
Chris' answer was definitely better than mine. 🙂 Use that!

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 13484 views
  • 0 likes
  • 6 in conversation