BookmarkSubscribeRSS Feed
jchamrad
Calcite | Level 5

I’m writing a VB.Net program that uses SASEGScripting to populate parameter values and run SAS EG projects. The particular project I’m using for testing contains three different parameter types: “ProjectParamTypeString(5)”, "ProjectParamTypeString(0)", and "ProjectParamTypeDate(0)".

 

"ProjectParamTypeString(5)" is easy enough, I simply assign a string value to Project.Parameter(i).Value. How do I assign values to the other two types? Is there some documentation on ProjectParamTypes and how to use them in .Net?

7 REPLIES 7
jchamrad
Calcite | Level 5
In this case, “ProjectParamTypeString(5)” is a list of strings and "ProjectParamTypeDate(0)" is a date range.
jchamrad
Calcite | Level 5
Correction: “ProjectParamTypeString(0)” is a list of strings
AlanC
Barite | Level 11

Please post a section of code so it provides some context. I use C# but might be able to help if I can see the context that you are referring to.

https://github.com/savian-net
jchamrad
Calcite | Level 5
Here's the code where I fill in parameters. I'm able to fill in the simple strings but not the date ranges and string lists. I expect there are underlying object types for each but I haven't been able to discover what they are.

Private Sub FillParams(ByRef params As SAS.EG.Scripting.ProjectParameterList)
For Each prm As SAS.EG.Scripting.ProjectParameter In params
Debug.WriteLine(prm.Name & " " & prm.Type.ToString & "(" & prm.Type & ")")
Select Case prm.Name
Case "uid" ' ProjectParmTypeString(5)
prm.Value = My.Settings.GalaxyUser
Case "upw_PASSWORD" ' ProjectParmTypeString(5)
prm.Value = My.Settings.GalaxyPw
Case "CSN" ' ProjectParmTypeString(5)
prm.Value = "'000188335'"
Case "PD_DT" ' ProjectParmTypeDate(0)
' Date range: From Date and Thru Date
' prm.Value = ?
Case "SVC_DT" ' ProjectParmTypeDate(0)
' Date range: From Date and Thru Date
' prm.Value = ?
Case "MY_NAME" ' ProjectParmTypeString(5)
prm.Value = "Lulu"
Case "DATABASE_SELECTION" ' ProjectParmTypeString(5)
' List of strings: "ABC","DEF","GHI"
' prm.Value = ?
End Select
Next
End Sub
jchamrad
Calcite | Level 5
Sorry, it re-formatted the code when I posted the reply.
AlanC
Barite | Level 11

EG is written (a lot) in C#. FRirst of all, I suggest using C# in .NET vs VB.NET: it will make your life easier...and is a better language IMO.

 

Let's take a look at one piece of code in your program (converted to C#): 

 

            // Date range: From Date and Thru Date
            // prm.Value = ?
            case "SVC_DT": // ProjectParmTypeDate(0)
                {
                    break;
                }

 

 

The type is Date so it expects a date. .NET does not have a Date type so you need to use  a DateTime value. Hence, it needs to either be cast or converted. Sample C# code:

 

prm.Value = (DateTime) ProjectParmTypeDate(0);

...or...
prm.Value = DateTime.Parse(ProjectParmTypeDate(0));

The right-hand side of the equals sign needs to match the type on the left. .NET (VB or C#), are strongly typed languages. if you are getting your parms as strings, they don't fit inside of a DateTime.

 

 

 

https://github.com/savian-net
jchamrad
Calcite | Level 5
I've been digging a little deeper and find that I may be asking the wrong question. In this particular project, the Parameters property of the Project object contains an entry named ‘PD_DT’. Turns out that ‘PD_DT’ refers to a Prompt. This prompt is defined as a ‘Date range’ with range type of ‘Custom’. In SAS EG, users are prompted for ‘From’ and ‘To’ dates. Where can I find this prompt in the Project object so I can enter the ‘From’ and ‘To’ dates programmatically ?

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 7 replies
  • 976 views
  • 0 likes
  • 2 in conversation