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!

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!

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.

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
  • 17 replies
  • 10508 views
  • 0 likes
  • 6 in conversation