Frequency Tabulations and Contingency Tables in SPSS

GET

FILE='D:\510\2007\werner.sav'.

RECODE

AGE

(Lowest thru 29=1) (30 thru 39=2) (40 thru Highest=3) INTO agegroup .

EXECUTE .

RECODE AGE (40 thru highest =1) (lowest thru 39=2) into hiage.

RECODE CHOL (240 thru highest =1) (lowest thru 239=2) into hichol.

RECODE CHOL (lowest thru 199=1) (200 thru 239 = 2) (240 thru highest=3) into cholcat.

RECODE WEIGHT (lowest thru 119 = 1) (120 thru 139 = 2) (140 thru highest=3) into wtcat.

Compute rpill = 3-pill.

Compute logwt = ln(weight).

Compute wtkg = weight * 0.39.

Compute htcm = height * 2.54.

Compute bmi = wtkg / (htcm/100)**2.

RECODE bmi (23.0000001 thru highest = 1) (lowest thru 23 = 2) into hibmi.

Execute.

Value labels agegroup (1) 1: 19-29 (2) 2: 30-39 (3) 3: >39

/hichol (1) 1: >=240 (2) 2: <240

/cholcat (1) 1: <200 (2) 2: 200-239 (3) 3: >=240

/pill (1) 1: No Pill (2) 2: Pill

/rpill (1) 1: Pill (2) 2: No Pill

/wtcat (1) 1: <120 (2) 2: 120-139 (3) 3: >=140

/hiage (1) 1: Yes (2) 2: No

/hibmi (1) 1: BMI>23 (2) 2: BMI<=23.

DESCRIPTIVES

VARIABLES=AGE HEIGHT WEIGHT PILL CHOL ALB CALCIUM ACID PAIR logwt agegroup hichol hiage cholcat wtcat wtkg htcm bmi

rpill hibmi

/STATISTICS=MEAN STDDEV MIN MAX .

/*Check recodes*/

MEANS

TABLES=weight BY wtcat

/CELLS MEAN COUNT min max .

MEANS

TABLES=AGE BY agegroup

/CELLS MEAN COUNT min max .

MEANS

TABLES=chol BY hichol

/CELLS MEAN COUNT min max .

MEANS

TABLES=chol BY cholcat

/CELLS MEAN COUNT min max.

CROSSTABS

/TABLES=PILL BY rpill

/FORMAT= AVALUE TABLES

/CELLS= COUNT

/COUNT ROUND CELL .

/*Oneway Frequencies*/

FREQUENCIES

VARIABLES=PILL wtcat agegroup hiage hichol cholcat

/ORDER= ANALYSIS .

/*Chisquare Goodness of Fit test*/

NPAR TEST

/CHISQUARE=hibmi

/EXPECTED=.20 .80

/MISSING ANALYSIS.

/* 2x2 Table*/

CROSSTABS

/TABLES=hiage BY hichol

/FORMAT= AVALUE TABLES

/STATISTIC=CHISQ RISK

/CELLS= COUNT ROW COLUMN TOTAL

/COUNT ROUND CELL .

/* 3x3 Table: Row Variable is Ordinal*/

CROSSTABS

/TABLES=agegroup BY hichol

/FORMAT= AVALUE TABLES

/STATISTIC=CHISQ

/CELLS= COUNT ROW

/COUNT ROUND CELL .

/* 3x3 Table: Both Row and Column Variables are Ordinal*/

CROSSTABS

/TABLES=agegroup BY wtcat

/FORMAT= AVALUE TABLES

/STATISTIC=CHISQ CORR GAMMA D BTAU CTAU

/CELLS= COUNT ROW

/COUNT ROUND CELL .

/* 2x2 Table: Stratified by WTCAT*/

CROSSTABS

/TABLES=hiage BY hichol BY wtcat

/FORMAT= AVALUE TABLES

/STATISTIC=CHISQ RISK CMH(1)

/CELLS= COUNT ROW

/COUNT ROUND CELL .

/* 3x3 Table: Stratified by WTCAT*/

CROSSTABS

/TABLES=agegroup BY cholcat BY wtcat

/FORMAT= AVALUE TABLES

/STATISTIC=CHISQ

/CELLS= COUNT ROW

/COUNT ROUND CELL .

********************************************************************

DESCRIPTIVES

VARIABLES=AGE HEIGHT WEIGHT PILL CHOL ALB CALCIUM ACID PAIR logwt agegroup hichol hiage cholcat wtcat wtkg htcm bmi

rpill hibmi

/STATISTICS=MEAN STDDEV MIN MAX .

/*Check recodes*/

MEANS

TABLES=weight BY wtcat

/CELLS MEAN COUNT min max .

MEANS

TABLES=AGE BY agegroup

/CELLS MEAN COUNT min max .

MEANS

TABLES=chol BY hichol

/CELLS MEAN COUNT min max .

MEANS

TABLES=chol BY cholcat

/CELLS MEAN COUNT min max

Means

Means

Means

Means

CROSSTABS

/TABLES=PILL BY rpill

/FORMAT= AVALUE TABLES

/CELLS= COUNT

/COUNT ROUND CELL .

/*Oneway Frequencies*/

FREQUENCIES

VARIABLES=PILL wtcat agegroup hiage hichol cholcat

/ORDER= ANALYSIS .

Frequencies

Frequency Table

/*Chisquare Goodness of Fit test*/

NPAR TEST

/CHISQUARE=hibmi

/EXPECTED=.20 .80

/MISSING ANALYSIS.

NPar Tests

Chi-Square Test

Frequencies

/* 2x2 Table*/

CROSSTABS

/TABLES=hiage BY hichol

/FORMAT= AVALUE TABLES

/STATISTIC=CHISQ RISK

/CELLS= COUNT ROW COLUMN TOTAL

/COUNT ROUND CELL .

Crosstabs

/* 3x3 Table: Row Variable is Ordinal*/

CROSSTABS

/TABLES=agegroup BY hichol

/FORMAT= AVALUE TABLES

/STATISTIC=CHISQ

/CELLS= COUNT ROW

/COUNT ROUND CELL .

Crosstabs

/* 3x3 Table: Both Row and Column Variables are Ordinal*/

CROSSTABS

/TABLES=agegroup BY wtcat

/FORMAT= AVALUE TABLES

/STATISTIC=CHISQ CORR GAMMA D BTAU CTAU

/CELLS= COUNT ROW

/COUNT ROUND CELL .

Crosstabs

/* 2x2 Table: Stratified by WTCAT*/

CROSSTABS

/TABLES=hiage BY hichol BY wtcat

/FORMAT= AVALUE TABLES

/STATISTIC=CHISQ RISK CMH(1)

/CELLS= COUNT ROW

/COUNT ROUND CELL .

/* 3x3 Table: Stratified by WTCAT*/

CROSSTABS

/TABLES=agegroup BY cholcat BY wtcat

/FORMAT= AVALUE TABLES

/STATISTIC=CHISQ

/CELLS= COUNT ROW

/COUNT ROUND CELL .

1