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
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.
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,
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.
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.
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!
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.