BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jbbell
Fluorite | Level 6

Is it possible to pass a parameter from Powershell into a SAS project with the application or project classes?  I am calling these to run SAS EG projects in an automated fashion based on lookups I'm doing out of Excel.  I have also found the projectparamter class in the scheduling documentation, but from my limited understanding these look more intended for pulling from a project than pushing into.

 

I have found some examples with VB using SYSPARAM, however, I'm yet to find an actual powershell call that does this so far.  I would prefer to house everything in powershell if possible.  Just trying to understand if I'm burning my time trying to figure it out in powershell.

1 ACCEPTED SOLUTION

Accepted Solutions
jbbell
Fluorite | Level 6

Chris,

 

Thanks for the quick response.  I was able to hack together a VB example I found with the API documentation.  Thought I would throw it back out here in case anyone in the future would like a working example.  Fair warning, all this does is create a new code node with the contents of $fileString.  Still working out the rest of the process, such as execution order and calling inside of a filter.  It's in a loop, but that is just because it's part of something I'm developing.  You don't really need the loop if you only have one project.

 

Also thanks for the documentation and github repo you have out there.  Was very helpful in trying to sort this out.

 


$Projects = 'Path/To/Project.egp'

 

foreach($project in $Projects) {
Write-Host "Processing SAS EG Project: " $project
$eguideApp = New-Object -ComObject SASEGObjectModel.Application.7.1
$egProject = $eguideApp.Open($project,"")
$fileString = "Your String to Pass"
$SASPgmObj = $egProject.CodeCollection.Add()
$SASPgmObj.Text = $fileString
$SASPgmObj.Run

$egProject.run()
$egProject.save()
$egProject.close()
$eguideApp.Quit()
Write-Host "Processed: " $project
}

View solution in original post

2 REPLIES 2
ChrisHemedinger
Community Manager

If you're using the SAS Enterprise Guide automation APIs, then anything you can do in VB Script can also be done in Powershell.  You've seen the examples in this article?

 

In terms of using automation to add content to a project, there aren't many options.  You can create a new Code item (SAS program) and run it via automation, but you can't add other types of objects like data, query tasks, or other types of tasks/flows.

Learn from the Experts! Check out the huge catalog of free sessions in the Ask the Expert webinar series.
jbbell
Fluorite | Level 6

Chris,

 

Thanks for the quick response.  I was able to hack together a VB example I found with the API documentation.  Thought I would throw it back out here in case anyone in the future would like a working example.  Fair warning, all this does is create a new code node with the contents of $fileString.  Still working out the rest of the process, such as execution order and calling inside of a filter.  It's in a loop, but that is just because it's part of something I'm developing.  You don't really need the loop if you only have one project.

 

Also thanks for the documentation and github repo you have out there.  Was very helpful in trying to sort this out.

 


$Projects = 'Path/To/Project.egp'

 

foreach($project in $Projects) {
Write-Host "Processing SAS EG Project: " $project
$eguideApp = New-Object -ComObject SASEGObjectModel.Application.7.1
$egProject = $eguideApp.Open($project,"")
$fileString = "Your String to Pass"
$SASPgmObj = $egProject.CodeCollection.Add()
$SASPgmObj.Text = $fileString
$SASPgmObj.Run

$egProject.run()
$egProject.save()
$egProject.close()
$eguideApp.Quit()
Write-Host "Processed: " $project
}

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