Hallo,
I'm have just started using EG 4.3 on Windows 7 to run about 250 jobs in batch via a remote server every night.I would like to direct the logs from these jobs to a central folder for further log scanning analysis. I'm thinking that I need to add some code to my VBScripts in order each project to direct the log to my predefined folder.Does anyone have a suggestion as to what I need to add to be below stated VBScript in order for this to succesfully happen?
Thanks!
Option Explicit
Dim app
Call dowork
'shut down the app
If not (app Is Nothing) Then
app.Quit
Set app = Nothing
End If
Sub dowork()
On Error Resume Next
'----
' Start up Enterprise Guide using the project name
'----
Dim prjName
Dim prjObject
prjName = "C:\_Services\Scheduling\finance.egp" 'Project Name
Set app = CreateObject("SASEGObjectModel.Application.4.3")
If Checkerror("CreateObject") = True Then
Exit Sub
End If
'-----
' open the project
'-----
Set prjObject = app.Open(prjName,"")
If Checkerror("app.Open") = True Then
Exit Sub
End If
'-----
' run the project
'-----
prjObject.run
If Checkerror("Project.run") = True Then
Exit Sub
End If
'-----
' Save the new project
'-----
prjObject.Save
If Checkerror("Project.Save") = True Then
Exit Sub
End If
'-----
' Close the project
'-----
prjObject.Close
If Checkerror("Project.Close") = True Then
Exit Sub
End If
End Sub
Function Checkerror(fnName)
Checkerror = False
Dim strmsg
Dim errNum
If Err.Number <> 0 Then
strmsg = "Error #" & Hex(Err.Number) & vbCrLf & "In Function " & fnName & vbCrLf & Err.Description
'MsgBox strmsg 'Uncomment this line if you want to be notified via MessageBox of Errors in the script.
Checkerror = True
End If
End Function
You can add a bit of script that will iterate through and export each SAS log that is produced in the project.
For background information, see:
Doing more with SAS Enterprise Guide automation - The SAS Dummy
with more examples from this sasCommunity.org page:
And specifically, this example:
http://support.sas.com/documentation/onlinedoc/guide/examples/SASGF2012/ExtractCodeAndLog.vbs.txt
Chris
Chris,
I saw the script ExtractCodeAndLog.vbs and found very useful. Now if I want to email the log file if there is an error in the code, how should I make the change?
As a general and possibly not welcome comment:
If this is about 250 jobs then scheduling using EG is may be the wrong approach as it needs a client computer with EG running. There is commercial scheduling software like LSF on the market which should be used. EG scheduling is imho only appropriate for some small scale scheduling tasks in a more "informal" environment. 250 jobs clearly exceed such a definition.
I agree with Patrick's sentiment on scalability.
However, I know that there are sometimes competing factors, including the ability to engage IT in the activity. With EG automation you can achieve some of the benefits of scheduling (including auditing logs) if you write your scripts correctly.
At some point you may outgrow that approach, or your IT organization may want to "operationalize" the process differently.
Chris
Another option would be to redirect the logs in SAS, rather than your script, using PROC PRINTTO.
--Q.
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.