Desktop productivity for business analysts and programmers

Scheduling an embedded code in SAS project

Reply
New Contributor
Posts: 3

Scheduling an embedded code in SAS project

Hi all

 

Hopefully someone could assist me on this as I am kind of stuck. Suppose I have a project file called: myproject.egp saved in C:\desktop with multiple embedded programs: myprogram1 myprogram2 myprogram3.

 

All I want to do is just run myprogram2 at a specific time later at 5pm. My SAS project is already opened so I all I require is to just let it run that program in that opened session. Afterwards, it should save. Could anyone suggest a way to do so? Thanks in advance!

 

Regards
Gareth

 

New Contributor
Posts: 3

Re: Scheduling an embedded code in SAS project

If it helps I am currently trying to modify the following script generated by EG's scheduler to suit my needs

 

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:\Desktop\myproject.egp"    'Project Name
      
    Set app = CreateObject("SASEGObjectModel.Application.5.1")
    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
New Contributor
Posts: 3

Re: Scheduling an embedded code in SAS project

Hi could anyone kindly assist please? Smiley Sad Thank you
Respected Advisor
Posts: 3,068

Re: Scheduling an embedded code in SAS project

It may be a lot easier just to export your embedded program and schedule it separately. If you only have a remote SAS server then you would need to schedule it on there. SAS Management Console provides scheduling capabilities but it does depend on how scheduling has been configured at your site.

Ask a Question
Discussion stats
  • 3 replies
  • 247 views
  • 0 likes
  • 2 in conversation