Hey !
We have long / large runs in SPSS and wonder if you can schedule finished syntaxes. Does anyone know if it is possible? //Elin |
Have you looked into Production Facility Mode which is designed to achieve this (and more)?
|
Hey !
Do you know if you need any special software for this? |
In reply to this post by Jignesh Sutar
Andrew Wheeler blogged about job automation on his site:
http://andrewpwheeler.wordpress.com/2014/12/03/automating-tasks-in-spss-using-production-jobs/ /PRogman |
In reply to this post by Elin_G
Dear All, I do run nightly scheduled runs with SPSS. It is quite simple -
Write the SPSS scripts you need -
Collect these to one or several SPSS production scripts (using several can help the error handling). I have two for collecting data.
One for joining the different data sources together and for exporting and saving the data on ‘permanent’ locations. And one for making all outputs (html-format so that everyone in the office can read them, despite of not having SPSS). -
Create a windows cmd script that runs the SPSS productionscripts.
-
Create ‘planned task’ (or what ever it is called in your operative system) that will run the cmd script. I have mine repeated daily at
22:00. Assuming that you know SPSS the tricky part is the cmd script. I will add here mine, in an unedited format. You will definitely need to edit it
so that it will suite your SPSS installation and needs. This script will check that SPSS is not running already, that needed folders exist, and then run four SPSS productionscripts, and play a beep when it is done. For those who do not use windows cmd scripts,
here are a few explanations that should get you started: :: is used for comments ‘SET’ is used to define variables like program locations, file names etc. %variablename% translates to its content when used later. ‘CALL’ will run a small piece of code with an name (the lines with CALL early in the script give the main structure of the execution) ‘GOTO :EOF’ means go to end of file, and marks the end of one piece of code.
IF SPSS is running there will be potentially errors in the data file, particularly if the data file that the productionscript is trying to save,
is already open. Therefore I kill any running SPSS processes (which means, that you will loose any unsaved changes in your scripts…) The rationale is that this productionrun (windows cmd) is normally run only at night time, and any open SPSS files, should
not be open… and producing correct data is more important than any ongoing analyses. In the end there are two different beeps using Python. One for OK and one for Error. I like this because the whole run is happening in the background,
and I prefer to be given information about the completion, without me needing to look for the results. If you do not use Python, you can just comment out the lines with BEEP. Good luck! Eero Olli ---------------------------------------------------------------------------------------- Senior Adviser, PhD at Equality and Anti-Discrimination Ombud, Norway :: made for Windows 7 and SPSS 22 by Eero Olli. :: This runs the same productionscripts as earlier :: Edited 15.09.2011 11:07:03 to work on portable computers. :: upgraded to SPSS v20 15.03.2012 :: upgraded to SPSS v21 05.06.2013 15:36:22 :: upgraded to SPSS v22 25.04.2014 09:43:26 @ECHO off :: the name of this cmd script ECHO Running now M:\dokumentasjon\SPSS-produksjon\update all SPSSv22.cmd :: These variables need to be changed when the setup is changed :: Where are the scripts and the program located? set scriptdrive=M: set scriptfolder=dokumentasjon\SPSS-produksjon\ set SPSSlocation=C:\Programfiler\IBM\SPSS\Statistics\22 set program="%SPSSlocation%\stats.exe" ECHO ON call :_timestamp1 ECHO off call :_KillSPSS call :_chkspssw call :_location ECHO ON call :_update1 call :_update2 call :_update3 call :_update4 call :_KillSPSS call :_timestamp2 GOTO :EOF :_update1 :: give the name of the script without including the folder. set skript="oppdater LDOsaker - del 1 SQLwebsak.spj" CALL :_chkscript ECHO Grab data from SQL server and other sources IF exist %skript% (start /wait "SPSS" %program% %skript% -production) GOTO :EOF :_update2 :: give the name of the script without including the folder. set skript="oppdater LDOsaker - del 2 skjemaer.spj" CALL :_chkscript ECHO Update data from SelectSurvey forms IF exist %skript% (start /wait "SPSS" %program% %skript% -production) GOTO :EOF :_update3 :: give the name of the script without including the folder. set skript="oppdater LDOsaker - del 3 koble.spj" CALL :_chkscript ECHO Update join all datasources to one big file and copy parts to SQL and ACCESS IF exist %skript% (start /wait "SPSS" %program% %skript% -production) GOTO :EOF :_update4 set skript="oppdater LDOsaker - del 4 - tabeller.spj" CALL :_chkscript ECHO Update all lists, tables and figures IF exist %skript% (start /wait "SPSS" %program% %skript% -production) GOTO :EOF :_location %scriptdrive% cd \%scriptfolder% ::ECHO script started %date% %time% ECHO. GOTO :EOF :_chkscript ECHO "**********************" IF exist %scriptfile% (ECHO productionscript is located ) ELSE GOTO :_problem GOTO :EOF :_KillSPSS ECHO make sure that spss production facility is not in use setlocal tasklist|find "stats.com">nul if %errorlevel% EQU 0 ( ECHO. ECHO SPSS Production facility is in use. ECHO it will be forcedly shut down. Sorry! ECHO. taskkill /f /im stats.com ) ELSE ( ECHO. echo SPSS Production facility is available ECHO. ) endlocal & GOTO :EOF :_chkspssw ECHO make sure that SPSS is not in use setlocal tasklist|find "spssengine.exe">nul if %errorlevel% EQU 0 ( ECHO. ECHO SPSS is already in use. ECHO it will be forcedly shut down. Sorry! ECHO. taskkill /f /im spssengine.exe ) ELSE ( ECHO. ECHO SPSS is available ECHO. ) endlocal & GOTO :EOF :_timestamp1 ECHO. ECHO script started at %date% %time% ECHO. %SPSSlocation%\Python\python.exe m:\dokumentasjon\python\beep_ok.py GOTO :EOF :_timestamp2 ECHO. ECHO script finished at %date% %time% ECHO. %SPSSlocation%\Python\python.exe m:\dokumentasjon\python\beep_ok.py GOTO :EOF :_problem ECHO something went wrong. %SPSSlocation%\Python\python.exe m:\dokumentasjon\python\beep_error.py pause exit. endlocal & GOTO :EOF Beep_error.py is a python file with following content: import winsound try: winsound.Beep(1000,200) winsound.Beep(1000,200) winsound.Beep(1000,200) winsound.Beep(1000,200) winsound.Beep(1000,200) except: print "\n***No sound" Beep_OK.py is a python file with following content: import winsound try: winsound.Beep(400,400) winsound.Beep(300,600) except: print "\n***No sound" |
Free forum by Nabble | Edit this page |