Assign variable label equal to variable name
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 | 'SPSS AnswerNet: Result Solution ID: 100007812 'Product: SPSS Tables 'Title: Variable names don't appear when creating a table 'Description: 'Q. 'I am running SPSS 8.0.2 Or higher For Windows. I created a table 'And I wanted the variable names To appear In the Output, 'but they don't. I looked under the Options->Output 'Labels window And I have Names selected For the "Variables 'In Labels Shown As" window. What is wrong? 'A. 'There Is a problem In SPSS 8.0.2 For Windows And later versions, 'but it can easily fixed by the user. Simply assign variable 'labels To the variables, And those variable labels can be the 'variable names themselves. For example, 'VARIABLE LABELS race "Race" gender "Gender". 'Then, when using SPSS Tables, the variable Name will 'appear In the Output. 'If you have many variables that don't have variable labels, 'assigning a variable label For Each of these variables may 'be cumbersome. Here Is a script that you may copy, paste 'into a New script window, And save In the Scripts folder of 'your SPSS directory. (Be sure To give it an .sbs extension.) 'Then, when you run this script, SPSS will assign the variable 'Name To those variables that Do Not have labels. Option Explicit Sub Main ' This script is to be run before you run the SPSS Tables commands. ' This script will look at the data file, find which variables do not ' have variable labels, and then run a VARIABLE LABELS command that ' inserts the variable name as the label. ' Declare variables and get the variable list: Dim objSpssInfo As ISpssInfo Set objSpssInfo = objSpssApp.SpssInfo ' Get the number of variables: Dim lngNumber As Long Dim i As Long Dim rotulo, comando As String lngNumber = objSpssInfo.NumVariables comando = "VARIABLE LABELS " For I = 0 To lngNumber - 1 rotulo=objspssinfo.VariableLabelAt(i) If rotulo = "" Then comando = comando + objspssinfo.VariableAt(i)+ " '" + objspssinfo.VariableAt(i)+ "' /" Next comando = comando + "." objSpssApp.ExecuteCommands comando, True End Sub |
Related pages
...