SAS Enterprise Guide

Desktop productivity for business analysts and programmers
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.

Register for SAS Innovate 2025!! The premier event for SAS users, May 6-9 in Orlando FL. Sign up now for the best deals!
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-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

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