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!
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
Register today and join us virtually on June 16!
sasglobalforum.com | #SASGF
View now: on-demand content for SAS users
Oh thank you! this is exactly the kind of thing I had in mind.
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?
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.
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).
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.