Racial IQ gap by SES in the NLSF (SPSS syntax)

Read the related page for syntax in other survey data.

Concerning the NLSF, which is a pretty bad organized data set, almost all the variables need to be recoded due to the fact that the original variables do not exclude missing values. More, importantly, the syntax won’t work for gender and race variables if you simply copy-paste it. It is because of quotation marks. Here’s the difference. The first line will end up with error message, the second line is the good one.

SPSS quotation marks

RECODE sex ('M'=0) ('F'=1) INTO SEX_variable.
 VARIABLE LABELS SEX_variable 'SEX_variable'.
 RECODE w1qzeth ('B'=1) ('W'=2) ('A'=3) ('H'=4) INTO RACE.
 VARIABLE LABELS RACE 'RACE variable'.

RECODE RACE (1 thru 2=COPY) (ELSE=SYSMIS) INTO BW.
RECODE RACE (lowest thru highest=COPY) INTO BWAH.

RECODE skincolr (0 thru 3=1) (4 thru 6=2) (7 thru 10=3) INTO SKINCOLOR3.
VARIABLE LABELS SKINCOLOR3 ‘SKINCOLOR_RECODED’.

RECODE w1q151 (1 thru 7=COPY) (ELSE=SYSMIS) INTO Mom_Educ.
RECODE w1q152 (1 thru 7=COPY) (ELSE=SYSMIS) INTO Dad_Educ.

RECODE w1q179 (1 thru 14=COPY) (ELSE=SYSMIS) INTO Household_Income.
RECODE w3q86 (1 thru 11=COPY) (ELSE=SYSMIS) INTO Parents_Household_Income.

RECODE Parents_Household_Income (1 thru 4=1) (5 thru 7=2) (8 thru 11=3) INTO Parental_Income3.

COMPUTE BW_ParentHHincome=BW*Parents_Household_Income.

RECODE w3q28a (400 thru 800=COPY) (ELSE=SYSMIS) INTO Verbal_Score.
RECODE w3q28b (400 thru 800=COPY) (ELSE=SYSMIS) INTO Quantitative_Score.
COMPUTE SAT_COMPOSITE=MEAN(Verbal_Score, Quantitative_Score).
RECODE w3q28c (1 thru 36=COPY) (ELSE=SYSMIS) INTO ACT_COMPOSITE.

REGRESSION
/MISSING LISTWISE
/STATISTICS COEFF OUTS R ANOVA
/CRITERIA=PIN(.05) POUT(.10)
/NOORIGIN
/DEPENDENT SAT_COMPOSITE
/METHOD=ENTER SEX_variable
/SAVE ZRESID.

RECODE ZRE_1 (lowest thru highest=COPY) INTO SAT_COMPOSITE_Sex.

REGRESSION
/MISSING LISTWISE
/STATISTICS COEFF OUTS R ANOVA
/CRITERIA=PIN(.05) POUT(.10)
/NOORIGIN
/DEPENDENT Verbal_Score
/METHOD=ENTER SEX_variable
/SAVE ZRESID.

RECODE ZRE_2 (lowest thru highest=COPY) INTO Verbal_Score_Sex.

REGRESSION
/MISSING LISTWISE
/STATISTICS COEFF OUTS R ANOVA
/CRITERIA=PIN(.05) POUT(.10)
/NOORIGIN
/DEPENDENT Quantitative_Score
/METHOD=ENTER SEX_variable
/SAVE ZRESID.

RECODE ZRE_3 (lowest thru highest=COPY) INTO Quantitative_Score_Sex.

REGRESSION
/MISSING LISTWISE
/STATISTICS COEFF OUTS R ANOVA
/CRITERIA=PIN(.05) POUT(.10)
/NOORIGIN
/DEPENDENT ACT_COMPOSITE
/METHOD=ENTER SEX_variable
/SAVE ZRESID.

RECODE ZRE_4 (lowest thru highest=COPY) INTO ACT_COMPOSITE_Sex.

DESCRIPTIVES VARIABLES=SAT_COMPOSITE ACT_COMPOSITE
/SAVE
/STATISTICS=MEAN STDDEV MIN MAX.

FREQUENCIES VARIABLES=skincolr Verbal_Score Quantitative_Score ZSAT_COMPOSITE ZACT_COMPOSITE
/FORMAT=NOTABLE
/HISTOGRAM NORMAL
/ORDER=ANALYSIS.

USE ALL.
COMPUTE filter_$=(ZSAT_COMPOSITE>-3).
VARIABLE LABELS filter_$ ‘ZSAT_COMPOSITE>-3 (FILTER)’.
VALUE LABELS filter_$ 0 ‘Not Selected’ 1 ‘Selected’.
FORMATS filter_$ (f1.0).
FILTER BY filter_$.
EXECUTE.

UNIANOVA ZSAT_COMPOSITE BY BW Parents_Household_Income WITH SEX_variable
/METHOD=SSTYPE(3)
/INTERCEPT=INCLUDE
/PLOT=PROFILE(Parents_Household_Income*BW)
/EMMEANS=TABLES(BW) WITH(SEX_variable=MEAN)
/EMMEANS=TABLES(Parents_Household_Income) WITH(SEX_variable=MEAN)
/EMMEANS=TABLES(BW*Parents_Household_Income) WITH(SEX_variable=MEAN)
/PRINT=LOF OPOWER ETASQ HOMOGENEITY DESCRIPTIVE
/PLOT=SPREADLEVEL RESIDUALS
/CRITERIA=ALPHA(.05)
/DESIGN=SEX_variable BW Parents_Household_Income BW*Parents_Household_Income.

FREQUENCIES VARIABLES=ZSAT_COMPOSITE SAT_COMPOSITE_Sex Verbal_Score_Sex Quantitative_Score_Sex
/FORMAT=NOTABLE
/HISTOGRAM NORMAL
/ORDER=ANALYSIS.

MEANS TABLES=ZSAT_COMPOSITE Verbal_Score Quantitative_Score SAT_COMPOSITE_Sex Verbal_Score_Sex Quantitative_Score_Sex BY BW
/CELLS MEAN COUNT STDDEV.

MEANS TABLES=ZSAT_COMPOSITE Verbal_Score Quantitative_Score SAT_COMPOSITE_Sex Verbal_Score_Sex Quantitative_Score_Sex BY Parental_Income3 BY BW
/CELLS MEAN COUNT STDDEV.

REGRESSION
/DESCRIPTIVES MEAN STDDEV CORR SIG N
/MISSING LISTWISE
/STATISTICS COEFF OUTS CI(95) R ANOVA COLLIN TOL CHANGE ZPP
/CRITERIA=PIN(.05) POUT(.10)
/NOORIGIN
/DEPENDENT ZSAT_COMPOSITE
/METHOD=ENTER SEX_variable BW Parents_Household_Income
/METHOD=ENTER BW_ParentHHincome
/PARTIALPLOT ALL
/SCATTERPLOT=(*ZRESID ,*ZPRED)
/RESIDUALS HISTOGRAM(ZRESID) NORMPROB(ZRESID).

REGRESSION
/DESCRIPTIVES MEAN STDDEV CORR SIG N
/MISSING LISTWISE
/STATISTICS COEFF OUTS CI(95) R ANOVA COLLIN TOL CHANGE ZPP
/CRITERIA=PIN(.05) POUT(.10)
/NOORIGIN
/DEPENDENT Verbal_Score
/METHOD=ENTER SEX_variable BW Parents_Household_Income
/METHOD=ENTER BW_ParentHHincome
/PARTIALPLOT ALL
/SCATTERPLOT=(*ZRESID ,*ZPRED)
/RESIDUALS HISTOGRAM(ZRESID) NORMPROB(ZRESID).

REGRESSION
/DESCRIPTIVES MEAN STDDEV CORR SIG N
/MISSING LISTWISE
/STATISTICS COEFF OUTS CI(95) R ANOVA COLLIN TOL CHANGE ZPP
/CRITERIA=PIN(.05) POUT(.10)
/NOORIGIN
/DEPENDENT Quantitative_Score
/METHOD=ENTER SEX_variable BW Parents_Household_Income
/METHOD=ENTER BW_ParentHHincome
/PARTIALPLOT ALL
/SCATTERPLOT=(*ZRESID ,*ZPRED)
/RESIDUALS HISTOGRAM(ZRESID) NORMPROB(ZRESID).

FILTER OFF.
USE ALL.
EXECUTE.

UNIANOVA ZACT_COMPOSITE BY BW Parents_Household_Income WITH SEX_variable
/METHOD=SSTYPE(3)
/INTERCEPT=INCLUDE
/PLOT=PROFILE(Parents_Household_Income*BW)
/EMMEANS=TABLES(BW) WITH(SEX_variable=MEAN)
/EMMEANS=TABLES(Parents_Household_Income) WITH(SEX_variable=MEAN)
/EMMEANS=TABLES(BW*Parents_Household_Income) WITH(SEX_variable=MEAN)
/PRINT=LOF OPOWER ETASQ HOMOGENEITY DESCRIPTIVE
/PLOT=SPREADLEVEL RESIDUALS
/CRITERIA=ALPHA(.05)
/DESIGN=SEX_variable BW Parents_Household_Income BW*Parents_Household_Income.

REGRESSION
/DESCRIPTIVES MEAN STDDEV CORR SIG N
/MISSING LISTWISE
/STATISTICS COEFF OUTS CI(95) R ANOVA COLLIN TOL CHANGE ZPP
/CRITERIA=PIN(.05) POUT(.10)
/NOORIGIN
/DEPENDENT ZACT_COMPOSITE
/METHOD=ENTER SEX_variable BW Parents_Household_Income
/METHOD=ENTER BW_ParentHHincome
/PARTIALPLOT ALL
/SCATTERPLOT=(*ZRESID ,*ZPRED)
/RESIDUALS HISTOGRAM(ZRESID) NORMPROB(ZRESID).

MEANS TABLES=ZACT_COMPOSITE ACT_COMPOSITE_Sex BY BW
/CELLS MEAN COUNT STDDEV.

MEANS TABLES=ZACT_COMPOSITE ACT_COMPOSITE_Sex BY Parental_Income3 BY BW
/CELLS MEAN COUNT STDDEV.

USE ALL.
COMPUTE filter_$=(BW=1).
VARIABLE LABELS filter_$ ‘BW=1 (FILTER)’.
VALUE LABELS filter_$ 0 ‘Not Selected’ 1 ‘Selected’.
FORMATS filter_$ (f1.0).
FILTER BY filter_$.
EXECUTE.

CORRELATIONS
/VARIABLES=skincolr ZACT_COMPOSITE ACT_COMPOSITE_Sex
/PRINT=TWOTAIL NOSIG
/MISSING=PAIRWISE.

NONPAR CORR
/VARIABLES=skincolr ZACT_COMPOSITE ACT_COMPOSITE_Sex
/PRINT=SPEARMAN TWOTAIL NOSIG
/MISSING=PAIRWISE.

MEANS TABLES=ZACT_COMPOSITE ACT_COMPOSITE_Sex BY SKINCOLOR3
/CELLS MEAN COUNT STDDEV.

FREQUENCIES VARIABLES=skincolr
/FORMAT=NOTABLE
/HISTOGRAM NORMAL
/ORDER=ANALYSIS.

USE ALL.
COMPUTE filter_$=(BW=1 and ZSAT_COMPOSITE>-3).
VARIABLE LABELS filter_$ ‘BW=1 and ZSAT_COMPOSITE>-3 (FILTER)’.
VALUE LABELS filter_$ 0 ‘Not Selected’ 1 ‘Selected’.
FORMATS filter_$ (f1.0).
FILTER BY filter_$.
EXECUTE.

CORRELATIONS
/VARIABLES=skincolr ZSAT_COMPOSITE Verbal_Score Quantitative_Score SAT_COMPOSITE_Sex Verbal_Score_Sex Quantitative_Score_Sex
/PRINT=TWOTAIL NOSIG
/MISSING=PAIRWISE.

NONPAR CORR
/VARIABLES=skincolr ZSAT_COMPOSITE Verbal_Score Quantitative_Score SAT_COMPOSITE_Sex Verbal_Score_Sex Quantitative_Score_Sex
/PRINT=SPEARMAN TWOTAIL NOSIG
/MISSING=PAIRWISE.

MEANS TABLES=ZSAT_COMPOSITE SAT_COMPOSITE_Sex BY SKINCOLOR3
/CELLS MEAN COUNT STDDEV.

FILTER OFF.
USE ALL.
EXECUTE.

FREQUENCIES VARIABLES=Parents_Household_Income Household_Income
/FORMAT=NOTABLE
/HISTOGRAM NORMAL
/ORDER=ANALYSIS.

This entry was posted in Stats, Softwares, Syntax and tagged . Bookmark the permalink.