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.

Check out SAS Innovate on-demand content! Watch the main stage sessions, keynotes, and over 20 technical breakout sessions!
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.

Check out SAS Innovate on-demand content! Watch the main stage sessions, keynotes, and over 20 technical breakout sessions!
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.

Check out SAS Innovate on-demand content! Watch the main stage sessions, keynotes, and over 20 technical breakout sessions!

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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