BookmarkSubscribeRSS Feed
Jensen_th
Calcite | Level 5

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

5 REPLIES 5
ChrisHemedinger
Community Manager

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:

http://www.sascommunity.org/wiki/Not_Just_for_Scheduling:_Doing_More_with_SAS_Enterprise_Guide_Autom...

And specifically, this example:

http://support.sas.com/documentation/onlinedoc/guide/examples/SASGF2012/ExtractCodeAndLog.vbs.txt

Chris

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
HashimBasheer
Fluorite | Level 6

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?

Patrick
Opal | Level 21

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.

ChrisHemedinger
Community Manager

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

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
Quentin
Super User

Another option would be to redirect the logs in SAS, rather than your script, using PROC PRINTTO.

--Q.

BASUG is hosting free webinars Next up: Jane Eslinger presenting PROC REPORT and the ODS EXCEL destination on Mar 27 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.

sas-innovate-2024.png

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.

 

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
  • 2183 views
  • 0 likes
  • 5 in conversation