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
'begin description
'Purpose: capitalize variable labels and value labels of all variables in working data file
'Requirement: 	must have data in data editor
'				folder c:\\temp\\ is assumed to exist
'Note: blank variable labels remains blank
'end description

'Posted to SPSSX-L list on 2002/12/21 by Raynald Levesque
'SPSS site: http://pages.infinit.net/rlevesqu/index.htm



Sub Main
	' Declare variables and get the SpssInfo object:
	Dim objSpssInfo As ISpssInfo
	Dim strVarName As String, lngLength As Long
	Dim strList ( ) As String
	Set objSpssInfo = objSpssApp.SpssInfo
	Open "C:\\temp\\labels.sps" For Output As #1

	' Get the number of value labels for the variable products:
	Dim varCount As Integer, I As Integer
	With objSpssInfo

		varCount = .NumVariables
		For I = 0 To varCount - 1
			strVarName = .VariableAt(I)
			' Get the variable label
			Print #1, "VARIABLE LABEL " & strVarName & " '" & UCase(.VariableLabelAt(I)) & "'."
			' Get the values and value labels
			Dim valCount As Integer, J As Integer
			valCount=.NumberOfValueLabels(I)

			If valCount > 0 Then
				ReDim strList (2, valCount)             'Declare a string array for the list
				Print #1,"ADD VALUE LABEL " & strVarName
				If  .VarType(I) = SpssDataString Then
				For J = 0 To valCount-1
					Print #1,"  '" & .ValueAt(I, J) & "'  '" & UCase(.ValueLabelAt (I, J)) & "'"
				Next
				Else
				For J = 0 To valCount-1
					Print #1,"  " & .ValueAt(I, J) & " '" & UCase(.ValueLabelAt (I, J)) & "'"
				Next
				End If
				Print #1,"."
			End If
		Next I
	End With
	Close #1
	objSpssApp.ExecuteInclude ("c:\\temp\\labels.sps",False)
	Set objSpssInfo = Nothing
End Sub