1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
*(Q) Every hour, I would like SPSS to automatically get data from an ODBC data base and 
	export HTML output to a given folder.
	

*(A) Posted to SPSS newsgroup on 2001/11/22 by Frank van Rooij 
I am a beginner in writing scripts but this worked well on my system
(SPSS 10.0.7):
You'll need 1 syntax file (*.sps) and 1 script file (*.sbs)


The syntax looks like this:

GET FILE='C:\\Data\\Datafile.sav'. 
* You'll use ODBC specifications here.

FREQUENCIES var1 .
* Assume your analysis is running frequencies

SCRIPT 'C:\\scripts\\script1.sbs'. 
* At the end of the syntax this script starts



The script looks like this:

Sub Main


' This command will export your output to HTML, 
' the HTML file will be overwritten each time:

    Dim objOutputDoc As ISpssOutputDoc	
    Set objOutputDoc=objSpssApp.GetDesignatedOutputDoc
    objSpssApp.Alerts = False	
	
    objOutputDoc.ExportDocument (SpssAll, "c:\\html\\outputfile.spo",
SpssFormatHtml, True)


	
'  This command will clear your output file,
'  so it will be ready for the next analysis:

	Set objOutputDoc=objSpssApp.GetDesignatedOutputDoc
	objOutputDoc.SelectAll
	objOutputDoc.Delete
	
	

' Waiting for 1 hour...

	Wait(3600)		' 3600 seconds = 1 hour 



' ...then start the syntax again (be sure no other syntax files are
opened):

	Dim objSyntaxDoc As ISpssSyntaxDoc
	Set objSyntaxDoc=objSpssApp.GetDesignatedSyntaxDoc
	objSyntaxDoc.Run
	
	
' And so on
	
End Sub



The procedure will end if you close the syntax file .