Data Analysis with IBM SPSS Statistics
上QQ阅读APP看书,第一时间看更新

Demo - adding variable properties via syntax

Here is the syntax to specify variable labels, value labels, missing values, and levels of measurement for the GSS 2014 data extract.

Here are the Variable Labels:

VARIABLE LABELS
ID "Respondent id number"
MARITAL "Marital status"
AGE "Age of respondent"
SEX "Respondents sex"
HAPPY "General happiness"
.

You can facilitate readability by providing one variable name and label per line. Note the period in its own line. That is not required, but makes the period easy to see.

Here are the Value Labels:

VALUE LABELS
MARITAL
1 "Married"
2 "Widowed"
3 "Divorced"
4 "Separated"
5 "Never married"
9 "No answer"
/ AGE
89 "89 or older"
98 "Don't know"
99 "No answer"
/ SEX
'f' "Female"
'm' "Male"
/ HAPPY
1 "Very happy"
2 "Pretty happy"
3 "Not too happy"
0 "Not applicable"
8 "Don't know"
9 "No answer"
.

For readability, enter one value and label per line. Note the use of the slash (/) as a separator. Additionally, as the codes for SEX are string values, enclose the values in matching quotes.

Here is the Missing Values specification:

MISSING VALUES
MARITAL(9)
/ AGE(98,99)
/ HAPPY(0,8,9)
.

For readability, specify one variable per line and use the slash as a separator.

Here is the Variable Level specification:

VARIABLE LEVEL
ID,AGE(SCALE)
/ HAPPY(ORDINAL)
/ MARITAL(NOMINAL)
.

As a shortcut, use lists to name variables that are the same Variable Level.

Select and run the syntax. The Variable View updates immediately. To see the effect of adding variable properties, here is the frequency table for MARITAL after executing the syntax and rerunning frequencies:

Now, the table has nice labels for the marital status categories, and the four cases with data codes of 9 are set off in a separate part of the table where the missing data is summarized.

aeaak