- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
}