BookmarkSubscribeRSS Feed
KermitTheFrog
Fluorite | Level 6

I am using the "Schedule Task" option with SAS EG (with the VBScript) to run a project during the night. 

When running it manually it works perfectly, however when it is using the Scheduler, every morning the same error appears: 

 

1          ;*';*";*/;quit;run;
2          OPTIONS PAGENO=MIN;
3          %put ERROR: Unable to get SAS code. Unable to find the specified file.;
ERROR: Unable to get SAS code. Unable to find the specified file.
4          
5          QUIT; RUN;

I checked the VBScript and the path to the file seems right.

 

Option Explicit
Dim app         ' As SASEGuide.Application

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     ' As String
    Dim prjObject   ' As SASEGuide.Project
    Dim containerName     ' As String
    Dim containerObject   ' As SASEGuide.Container
    Dim containerColl     ' As SASEGuide.ContainerCollection

    prjName = "F:\path\to\my\file.egp" ' Project Name
    containerName = "Process Flow" ' Container Name
      
    Set app = CreateObject("SASEGObjectModel.Application.8.1")
    If Checkerror("CreateObject") = True Then
        Exit Sub
    End If
    
    Set prjObject = app.Open(prjName,"")
    If Checkerror("App.Open") = True Then
        Exit Sub
    End If
    
        
    '-----
    'Get The Container Collection and Object
    '-----    
    Set containerColl = prjObject.ContainerCollection
    If Checkerror("Project.ContainerCollection") = True Then
        Exit Sub
    End If
    
    Dim i       ' As Long
    Dim count   ' As Long
    count = containerColl.count
    For i = 0 To count - 1
        Set containerObject = containerColl.Item(i)
        If Checkerror("ContainerCollection.Item") = True Then
            Exit Sub
        End If
        
        If (containerObject.Name = containerName) Then
            Exit For
        Else
            Set containerObject = Nothing
        End If
    Next 
    
    If not (containerObject Is Nothing) Then
        '----
        ' Run the Container
        '----
        containerObject.Run
        If Checkerror("Container.Run") = True Then
            Exit Sub
        End If               
    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      ' As String
    Dim errNum      ' As Long
    
    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

Am I missing something ? 

 

2 REPLIES 2
ChrisNZ
Tourmaline | Level 20

It looks like the F: drive is unavailable to the scheduler.

This about why this could be the case on your machine,

A common reason is that it's a network drive unauthorised to the user chosen to run the batch job.

ChrisNZ
Tourmaline | Level 20

Also: Maybe use the UNC oath instead of a mapped drive letter.

Mapping drives is best avoided, it creates all sorts of problems.

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 2 replies
  • 1458 views
  • 0 likes
  • 2 in conversation