BookmarkSubscribeRSS Feed
isek
Obsidian | Level 7

Hello,
I want to run an automated lock project.

 

First solution :
I tried to do it via the scheduler sas EG, it returns me an error to the execution

 

second solution :

 

I coded a powershell script that launches my project, I have a problem with the launch of sasEG.

script in my cmd.exe

 

powershell New-Object -ComObject SASEGObjectModel.Application.7.1 

Did anyone have the same problem as me? Does anyone have a solution to offer me?

 

I think it's a problem of version but I do not know how to proceed

 

Thanks 

 

5 REPLIES 5
ChrisHemedinger
Community Manager

Make sure that you're running the scripting engine (PowerShell or VBScript) that matches the bitness of the EG you have.  If running 32-bit EG, then you need the 32-bit cscript.exe or powershell.

 

I have a note about this in this blog post.

SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!
MarcoRQ
Calcite | Level 5

Is there a way to retrieve the error in powershell ?

This is an example of my powershell script:

$sas = New-Object -comObject SASEGObjectModel.Application.7.1

$App=$sas.Open("C:\temp\myTestFile.egp","")

Foreach($parametre in $App.Parameters)
{
If ($parametre.Name -eq "USER")
{
$parametre.Value='MyUser'
}
If ($parametre.Name -eq "PASSWORD")
{
$parametre.Value='{sas002}MyPasswordEncrypted'
}
}

Try {
$output = $App.run() #<======= How can I get the error here ???
Write-Host "Result: " $output}
Catch{
Write-Host "An error occurred:"
Write-Host $_
}
Finally{
$App.save()
$App.close()
$sas.quit()
}



In my sas macro, I simulate an error by inserting the same row 2 times so I want this error reported in the powershell script
proc sql;
insert into MyConnection.MyTable select * from to_insert;
%if &SQLRC > 0 %then %do;
%put ERROR: Error happened!;
%abort ABEND;
%end;
quit;

Regards,

ChrisHemedinger
Community Manager

To get the SAS log, you will need to use the automation object model to navigate the project and retrieve the log objects from each task to find the error. There are some examples here in VBScript that you can look at for ideas.

SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!
isek
Obsidian | Level 7
thank you for your reply.
I have a second problem which is that I have two versions of Sas guide one in 4.3 and one in 7.1 so can this also be a problem when I run on version 7.1?
Thank you for your time
ChrisHemedinger
Community Manager

The scripting engine has a version-specific object ID.  V7.1 can be either 32- or 64-bit, so you have to verify which you have and then use the proper version of PowerShell.

SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 5 replies
  • 1990 views
  • 0 likes
  • 3 in conversation