Desktop productivity for business analysts and programmers

How would I run a project on the condition of an oustside file being saved

Reply
New Contributor
Posts: 3

How would I run a project on the condition of an oustside file being saved

I would like to be able to have a project run when I have saved an excel file. This file is being uploaded from a folder and I was curious if I could use the condition setting on this and a macro possibly that will detect when the file has been modified. For example the file was saved. Then the project runs and the file is uploaded into SAS and used in the project. Any advice or help would be greatly appreciated!

SAS Super FREQ
Posts: 307

Re: How would I run a project on the condition of an oustside file being saved

This VBScript code below from the blog link below slightly modified to run the EG project worked for me.  It triggers specifically when a file is added to a folder, but I imagine it could be altered to listen for file modification instead.

(Note: EGScript1.vbs is the vbs file created when you schedule a project from within EG.)

' See http://blogs.technet.com/b/heyscriptingguy/archive/2004/10/11/how-can-i-automatically-run-a-script-a...
' Save as and run FileSystemWatcher.vbs and it'll start a wscript.exe process

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & _
        strComputer & "\root\cimv2")
Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
    ("SELECT * FROM __InstanceCreationEvent WITHIN 10 WHERE " _
        & "Targetinstance ISA 'CIM_DirectoryContainsFile' and " _
            & "TargetInstance.GroupComponent= " _
                & "'Win32_Directory.Name=""c:\\\\scripts""'")
Do
    Set objLatestEvent = colMonitoredEvents.NextEvent
    Wscript.Echo objLatestEvent.TargetInstance.PartComponent

'Run the EG project
Dim objShell
Set objShell = Wscript.CreateObject("WScript.Shell")

objShell.Run "C:\Users\cassmi\Desktop\EGScript1.vbs"

' Using Set is mandatory
Set objShell = Nothing

Loop

New Contributor
Posts: 3

Re: How would I run a project on the condition of an oustside file being saved

Oh thank you! this is exactly the kind of thing I had in mind.

Trusted Advisor
Posts: 3,208

Re: How would I run a project on the condition of an oustside file being saved

Why not have the excel stored at the SAS server and have the presence and triggering handled there. You can go home enjoy your time off while the computer is working.
You can also choose to work 24*7 on a computer with Eguide being a robot. In that case no automation is needed as there is a robot. What are your requirements?

---->-- ja karman --<-----
New Contributor
Posts: 3

Re: How would I run a project on the condition of an oustside file being saved

How would you set up the triggering from there? I could probably set it up so that the incoming data is assigned to the SAS server. Currently it is a spreadsheet received from a vendor. I was planning to have it always just be saved under the same name so when the new one come in its downloaded and saved in the same spot and a macro would trigger when the file is modified and trigger the project to run through a project condition linked to this macro. However I could get this folder assigned to the SAS server and skip the uploading part. How would I set up SAS to run a project if a file were updated that was stored in the SAS server?

And I very much appreciate the help so far I just started working with SAS EG but there seem to be tons of cool things you can do with it.

Trusted Advisor
Posts: 3,208

Re: How would I run a project on the condition of an oustside file being saved

When you receive data from an external source it can be weekly monthly quartely in that case manual actions will be sufficient. Hardly any cost improvement when getting automated.
When you receive data daily/weekly a MFT (managed File transfer Program) can drop it a location on the server.  A scheduler has mostly options to recognize an trigger a batch job. This is common IT operations work.  The batch program the scheduler is starting can be a SAS batch script on the server  (Batch server LSF etc in SAS terms).  

---->-- ja karman --<-----
Ask a Question
Discussion stats
  • 5 replies
  • 429 views
  • 6 likes
  • 3 in conversation