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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
*(Q) Is it possible to write with syntax an elaborate title in CROSSTAB
 command.
* When I generate multiples crosstabs weekly, I dont want rewrite the
 titles each time.


*(A) I've written a script and a macro to get custom titles in the output.
* The script is named 'title.sbs' and the macro 'title.sps'. Both should
* be stored in the same directory (). You get your custom title
* using the following syntax:

include '\title.sps'.
CROSSTABS something BY somethingelse.
settitle This is a custom title.
dotitle.
CROSSTABS blabla1 BY blabla2.
settitle This is another custom title.
dotitle.


First the script (store it as \title.sbs):

==============================================================
Sub Main()
  Dim objOutputDoc As ISpssOutputDoc
  Dim objItems As ISpssItems
  Dim objItem As ISpssItem
  Dim myindex As Long
  Dim lab As String
  Dim objSPSSText As ISpssrtf
  Dim mytitle As String
  Set objOutputDoc = objSpssApp.GetDesignatedOutputDoc
  Set objItems = objOutputDoc.Items()
  myindex=objItems.Count
  Set objItem = objItems.GetItem(myindex-1)
  Set objSPSSText =objItem.ActivateText
  mytitle=objSPSSText.Text
  objItem.Deactivate
  Do
    myindex=myindex-1
    Set objItem = objItems.GetItem(myindex)
    lab=objitem.Label
  Loop Until lab="Title"
  objitem.label=mytitle
  Set objSPSSText =objItem.ActivateText
  objSPSSText.Text=mytitle
  objItem.Deactivate
  objItem.Selected=False
  Set objItem = objItems.GetItem(objItems.Count-1)
  objitem.Selected=True
  objOutputDoc.Remove
End Sub
==============================================================


And the macro (\title.sps):

==============================================================
define settitle (!POSITIONAL !CMDEND).
do if $CASENUM EQ 1.
print /!quote(!1).
end if.
execute.
!ENDDEFINE.

define dotitle().
script '\title.sbs' .
!ENDDEFINE.
==============================================================



Hope this helps.

Oliver Loch


----------------------------------------------------------------------------
Dipl. Stat. Oliver Loch
German AIDS Study Group              Phone:  +49 89 5160 3457
Med. Poliklinik der LMU              Fax:    +49 89 5160 3593
Pettenkoferstr. 8a                   e-mail:
loch@pk-i.med.uni-muenchen.de
D-80336 Muenchen
----------------------------------------------------------------------------