* File ex3.sps analysis of Scottish Health Survey 1998

data on smoking rates.

* We assume you have already opened the data file ex3.sav.

* Now define the survey design

This can be done interactively via the Analyze and following the responses in the dialogue box.

* Analysis Preparation Wizard. This model uses One Stage and assumes sampling With Replacement

the code below was made by pasting at the last stage of the dialogue box.

CSPLAN ANALYSIS

/PLAN FILE='C:\Documents and Settings\gillian raab\My Documents\aprojects\peas\web\exemp3\program_code\ex3.csaplan'

/PLANVARS ANALYSISWEIGHT=grosswt

/PRINT PLAN

/DESIGN STRATA= regstrat CLUSTER= psu

/ESTIMATOR TYPE=WR.

* Now

* Complex Samples Frequencies for smoking groups.

CSTABULATE

/PLAN FILE = 'C:\Documents and Settings\gillian raab\My Documents\aprojects\peas\web\exemp3\program_code\ex3.csaplan'

/TABLES VARIABLES = cigst2

/CELLS POPSIZE TABLEPCT

/STATISTICS SE CIN(95) COUNT DEFF DEFFSQRT

/MISSING SCOPE = TABLE CLASSMISSING = EXCLUDE.

* Now recode to get a group of cigarette smokers.

RECODE

cigst2

(-8=SYSMIS) (-9=SYSMIS) (-6=SYSMIS) (-1=0) (1=1) (5=0) (2=2) (3=1) (4=1) INTO smoker .

VARIABLE LABELS smoker 'current cigarette smoker'.

EXECUTE .

RECODE

cigst2

(-8=SYSMIS) (-9=SYSMIS) (-6=SYSMIS) (-1=0) (1=1) (5=0) (2=1) (3=1) (4=1) INTO smoker .

VARIABLE LABELS smoker 'current cigarette smoker'.

EXECUTE .

 

 

* Complex Samples Frequencies for smoker.

CSTABULATE

/PLAN FILE = 'C:\Documents and Settings\gillian raab\My Documents\aprojects\peas\web\exemp3\program_code\ex3.csaplan'

/TABLES VARIABLES = smoker

/CELLS POPSIZE TABLEPCT

/STATISTICS SE CIN(95) COUNT DEFF DEFFSQRT

/MISSING SCOPE = TABLE CLASSMISSING = EXCLUDE.

* Complex Samples Frequencies for smoker by male/female.

CSTABULATE

/PLAN FILE = 'C:\Documents and Settings\gillian raab\My Documents\aprojects\peas\web\exemp3\program_code\\ex3.csaplan'

/TABLES VARIABLES = smoker

/SUBPOP TABLE = sex

/CELLS TABLEPCT

/STATISTICS SE COUNT DEFF DEFFSQRT

/MISSING SCOPE = TABLE CLASSMISSING = EXCLUDE.

 

* Complex Samples Frequencies for smoker by health board.

CSTABULATE

/PLAN FILE = 'C:\Documents and Settings\gillian raab\My Documents\aprojects\peas\web\exemp3\program_code\ex3.csaplan'

/TABLES VARIABLES = smoker

/SUBPOP TABLE = hboard

/CELLS TABLEPCT

/STATISTICS SE COUNT DEFF DEFFSQRT

/MISSING SCOPE = TABLE CLASSMISSING = EXCLUDE.

* look at smoking by social class first recoding missing data.

RECODE

sc

(-8=SYSMIS) (-9=SYSMIS) (-6=SYSMIS) (-1=sysmis) (else =copy) INTO sc .

EXECUTE .

* Complex Samples Frequencies for smoker by social class.

CSTABULATE

/PLAN FILE = 'C:\Documents and Settings\gillian raab\My Documents\aprojects\peas\web\exemp3\program_code\ex3.csaplan'

/TABLES VARIABLES = smoker

/SUBPOP TABLE = sc

/CELLS TABLEPCT

/STATISTICS SE COUNT DEFF DEFFSQRT

/MISSING SCOPE = TABLE CLASSMISSING = EXCLUDE.