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

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

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!
Quentin
Super User

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

--Q.

The Boston Area SAS Users Group is hosting free webinars!
Next up: Lisa Mendez & Richann Watson present Get Tipsy with Debugging Tips for SAS® Code: The After Party on Wednesday Jul 16.
Register now at https://www.basug.org/events.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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