Top Banner
Multiple Indicator Cluster Surveys Data Processing Workshop SPSS general commands Overview MICS Data Processing Workshop
44

Multiple Indicator Cluster Surveys Data Processing Workshop SPSS general commands Overview MICS Data Processing Workshop.

Dec 29, 2015

Download

Documents

Lora Anderson
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Multiple Indicator Cluster Surveys Data Processing Workshop SPSS general commands Overview MICS Data Processing Workshop.

Multiple Indicator Cluster SurveysData Processing Workshop

SPSS general commandsOverview

MICS Data Processing Workshop

Page 2: Multiple Indicator Cluster Surveys Data Processing Workshop SPSS general commands Overview MICS Data Processing Workshop.

IBM SPSS Statistics Statistical Package for the Social Sciences• SPSS is a full-featured data analysis program that offers a 

variety of applications including  data base management, statistical analysis and graphics• The SPSS program runs on a wide variety of mainframe, 

mini, and microcomputers• The most recent version is SPSS 21, which runs on both 

Windows , Linux and Mac OS desktop platforms• www.ibm.com/software/analytics/spss

Page 3: Multiple Indicator Cluster Surveys Data Processing Workshop SPSS general commands Overview MICS Data Processing Workshop.

Data management using the SPSS Statistics command language

• Getting Data into SPSS Statistics• Merging data• Aggregating data• Weighting data• And many more

Page 4: Multiple Indicator Cluster Surveys Data Processing Workshop SPSS general commands Overview MICS Data Processing Workshop.

.SAV File Extension• Data file created by SPSS is saved in a proprietary binary format and contains a dataset as well as a dictionary that describes the dataset; saves data by "cases" (rows) and "variables" (columns)

• .SAV files are can store data extracted from other databases and Microsoft Excel spreadsheets.

• .SAV files can also save data that has been entered manually by the user or data that has been generated by the software

• SPSS datasets can be manipulated in a variety of ways using the SPSS engine

Page 5: Multiple Indicator Cluster Surveys Data Processing Workshop SPSS general commands Overview MICS Data Processing Workshop.

Programming with SPSS Statistics

• Although many of the tasks can be performed with the menus and dialog boxes, some very powerful features are available only with command syntax

Page 6: Multiple Indicator Cluster Surveys Data Processing Workshop SPSS general commands Overview MICS Data Processing Workshop.

Programming with SPSS Statistics

• Build and run command syntax• Get data, add new variables, and append cases to the active dataset

• Create new datasets• Concurrently access multiple open datasets• Get output results• Create tables

Page 7: Multiple Indicator Cluster Surveys Data Processing Workshop SPSS general commands Overview MICS Data Processing Workshop.

Creating Command Syntax Files.SPS File Extension

• .SPS file is a program file used by SPSS, a statistical analysis application; saved in a plain text format and contains instructions written using the SPSS syntax; generally developed with the SPSS Syntax Editor; used for manipulating datasets and automating statistical analyses

• You can use any text editor to create a command syntax file, but SPSS Statistics provides a number of tools to make your job easier

Page 8: Multiple Indicator Cluster Surveys Data Processing Workshop SPSS general commands Overview MICS Data Processing Workshop.

Creating Command Syntax Files

• SPSS program commands follow very specific syntax rules, which are described in various SPSS publications:

• All commands must begin in the first column of a line and be spelled correctly

 

Page 9: Multiple Indicator Cluster Surveys Data Processing Workshop SPSS general commands Overview MICS Data Processing Workshop.

Creating Command Syntax Files

• Most commands include additional information (e.g., names of variables the command is to be applied to, options for processing data, displaying results, etc.)which may be continued on the same line using the appropriate delimiter (e.g., blank space, comma, slash)

• or continued on an additional line(s) provided that the continuation begins after column 1

Page 10: Multiple Indicator Cluster Surveys Data Processing Workshop SPSS general commands Overview MICS Data Processing Workshop.

Creating Command Syntax Files

• Commands can be typed in either upper or lower case

• Most SPSS commands have default specifications, i.e., the options that will be used unless you tell SPSS to use something else

• Use the Paste button. Make selections from the menus and dialog boxes, and then click the Paste button instead of the OK button. This will paste the underlying commands into a command syntax window

Page 11: Multiple Indicator Cluster Surveys Data Processing Workshop SPSS general commands Overview MICS Data Processing Workshop.

Overview of the commands

•  Data definition•  File interfaces•  Analyze data•  Modify data

Page 12: Multiple Indicator Cluster Surveys Data Processing Workshop SPSS general commands Overview MICS Data Processing Workshop.

Data definition

These commands:1. bring raw data into SPSS, either from 

another file, or by typing it in yourself, and 

2. enter descriptive information about the data

Page 13: Multiple Indicator Cluster Surveys Data Processing Workshop SPSS general commands Overview MICS Data Processing Workshop.

Data definition

Commands:DATA LISTVARIABLE LABELSVALUE LABELSMISSING VALUES

Page 14: Multiple Indicator Cluster Surveys Data Processing Workshop SPSS general commands Overview MICS Data Processing Workshop.

Data list

• DATA LIST defines a raw data file (data file containing numbers and other alphanumeric characters) by assigning names and formats to each variable in the file

EXAMPLE:DATA LIST FILE='C:\MICS5\SPSS\MYHH.DAT' RECORDS=1

Page 15: Multiple Indicator Cluster Surveys Data Processing Workshop SPSS general commands Overview MICS Data Processing Workshop.

Variable and value labels• VARIABLE and VALUE LABELS commands delete all existing variable and value labels for the specified variable(s) and assign new variable and value labels. 

• ADD VALUE LABELS can be used to add new labels or alter labels for specified values without deleting other existing labels.

EXAMPLEvariable labels type "Main source of drinking water".value labels type 1 "Improved sources"2 "Unimproved sources".

Page 16: Multiple Indicator Cluster Surveys Data Processing Workshop SPSS general commands Overview MICS Data Processing Workshop.

File interfaces

File interfaces commands access and save SPSS system files

Commands:

GET FILESAVE OUTFILE

Page 17: Multiple Indicator Cluster Surveys Data Processing Workshop SPSS general commands Overview MICS Data Processing Workshop.

Get file

• GET FILE  opens an SPSS data file.• SAVE produces a data file in SPSS Statistics format, which contains data plus a dictionary. The dictionary contains a name for each variable in the data file plus any assigned variable and value labels, missing-value flags, and variable print and write formats. 

EXAMPLE:get file = 'hh.sav'.save outfile = 'hh.sav'.

Page 18: Multiple Indicator Cluster Surveys Data Processing Workshop SPSS general commands Overview MICS Data Processing Workshop.

Analyze data•  Commands that actually perform statistical analysis

EXAMPLEfrequencies  variables=hc2 hc3 hc4 hc5 hc6 hc8 hc8a

         ws1 ws2 ws7  /statistics=stddev mean  /order=analysis.

Page 19: Multiple Indicator Cluster Surveys Data Processing Workshop SPSS general commands Overview MICS Data Processing Workshop.

Modify data

• Commands that alter data and change file characteristics.

Commands:COMPUTERECODEIFSELECT IF

Page 20: Multiple Indicator Cluster Surveys Data Processing Workshop SPSS general commands Overview MICS Data Processing Workshop.

Compute

• Creates a new variable in the dataset:COMPUTE target variable=expression

EXAMPLEcompute persroom = 99.if (hc2 < 98) persroom = hh11/hc2.variable label persroom 'Persons per sleeping rooms'.missing values persroom (99).

Page 21: Multiple Indicator Cluster Surveys Data Processing Workshop SPSS general commands Overview MICS Data Processing Workshop.

Recode• RECODE changes, rearranges, or consolidates the values of an 

existing variable. RECODE can be executed on a value-by-value basis or for a range of values. 

• Where it can be used, RECODE is much more efficient than the series of IF commands that produce the same transformation.

• With RECODE, you must specify the new values.EXAMPLE.recode improved (100 = 1) (else = 2) into type.variable labels WS1 "".variable labels type "Main source of drinking water".value labels type 1 "Improved sources"2 "Unimproved sources".

Page 22: Multiple Indicator Cluster Surveys Data Processing Workshop SPSS general commands Overview MICS Data Processing Workshop.

IF• The IF command conditionally executes one or more transformations based on one or more logical expressions. 

EXAMPLE.compute improved = 0.if (WS1 = 11 or  WS1 = 12 or WS1 = 13 or WS1 = 14 or WS1 = 15 or WS1 = 21 or WS1 = 31 or WS1 = 41 or 

  WS1 = 51) improved = 100.if ((WS2 = 11 or WS2 = 12 or WS2 = 13 or WS1 = 14 or WS1 = 15 or WS2 = 21 or WS2 = 31 or WS2 = 41 or 

  WS2 = 51) and WS1 = 91) improved = 100. variable label improved "Percentage of household population using improved sources of drinking water ".

Page 23: Multiple Indicator Cluster Surveys Data Processing Workshop SPSS general commands Overview MICS Data Processing Workshop.

SELECT IF• SELECT IF permanently selects cases for analysis based on logical conditions that are found in the data. These conditions are specified in a logical expression. 

• For temporary case selection, it is necessary to specify a TEMPORARY command before SELECT IF.

EXAMPLE.select if (hh9 = 1).select if (wm7 = 1).select if (mwm7 = 1).select if (uf9 = 1).

Page 24: Multiple Indicator Cluster Surveys Data Processing Workshop SPSS general commands Overview MICS Data Processing Workshop.

MERGING FILES IN SPSSMATCH FILES command

• MATCH FILES combines variables from 2 up to 50 SPSS Statistics data files. 

• MATCH FILES can make parallel or nonparallel matches between different files or perform table lookups. 

• Parallel matches combine files sequentially by case (they are sometimes referred to as sequential matches). Nonparallel matches combine files according to the values of one or more key variables.

• In general, MATCH FILES is used to combine files containing the same cases but different variables. 

Page 25: Multiple Indicator Cluster Surveys Data Processing Workshop SPSS general commands Overview MICS Data Processing Workshop.

MERGING FILES IN MICS5• 4 – 9 SPSS MICS5 data files are produced for each survey, 

corresponding to the main units of analysis: o Households - hh.sav o Household members - hl.savo Women in reproductive age (15-49 years of age) – wm.savo FGM – fg.savo Birth history – bh.savo Treated nets – tn.savo Maternal mortality – mm.savo Men (15 – 49 years of age) – mn.savo Children under the age of five – ch.sav

Page 26: Multiple Indicator Cluster Surveys Data Processing Workshop SPSS general commands Overview MICS Data Processing Workshop.

MERGING FILES IN MICS5

HH.sav• Relations with: 

hl.sav, wm.sav, ch.sav, bh.sav, fg.sav, tn.sav, mn.sav

• Base key variables:   HH1 (cluster number) and HH2 (household number)

Page 27: Multiple Indicator Cluster Surveys Data Processing Workshop SPSS general commands Overview MICS Data Processing Workshop.

MERGING FILES IN MICS5

HL.sav• Relations with: 

wm.sav, ch.sav, bh.sav, fg.sav, mn.sav

• Base key variables:   HH1 (cluster number) and HH2 (household number)

    LN (HL1) (member’s line number)

Page 28: Multiple Indicator Cluster Surveys Data Processing Workshop SPSS general commands Overview MICS Data Processing Workshop.

MERGING FILES IN MICS5

WM.sav, CH.sav, MN.sav• Relations with: hh.sav, hl.sav

• Base key variables: HH1 (cluster number), HH2 (household number) and LN (HL1) (member’s line number)

IMPORTANT NOTE: variable HL1 in hl.sav data file is named LN in wm.sav ,ch.sav and mn.sav files. Renaming of the variable is required prior to merging.

Page 29: Multiple Indicator Cluster Surveys Data Processing Workshop SPSS general commands Overview MICS Data Processing Workshop.

MERGING FILES IN MICS5

BH.sav• Relations with: hh.sav, hl.sav, wm.sav

• Base key variables: HH1 (cluster number), HH2 (household number) and HL1 (member’s line number)

Page 30: Multiple Indicator Cluster Surveys Data Processing Workshop SPSS general commands Overview MICS Data Processing Workshop.

MERGING FILES IN MICS5

MM.sav• Relations with: hh.sav, hl.sav, wm.sav

• Base key variables: HH1 (cluster number), HH2 (household number) and LN (member’s line number)

Page 31: Multiple Indicator Cluster Surveys Data Processing Workshop SPSS general commands Overview MICS Data Processing Workshop.

MERGING FILES IN MICS5

TN.sav• Relations with: hh.sav, hl.sav

• Base key variables: HH1 (cluster number), HH2 (household number) and HL1 (member’s line number)

Page 32: Multiple Indicator Cluster Surveys Data Processing Workshop SPSS general commands Overview MICS Data Processing Workshop.

Example on how to merge hh.sav onto a wm.sav

• Make sure both files are sorted in ascending order by key variables before trying to merge.

Page 33: Multiple Indicator Cluster Surveys Data Processing Workshop SPSS general commands Overview MICS Data Processing Workshop.

Example on how to merge hh.sav onto a wm.sav

• From the menus choose: Data…. Merge Files…. Add Variables...

Page 34: Multiple Indicator Cluster Surveys Data Processing Workshop SPSS general commands Overview MICS Data Processing Workshop.

Example on how to merge hh.sav onto a wm.sav

• Select the file you wish to merge:

If the file is already open select it from the list of „an open dataset“, and if it is not then browse for the file.  

Page 35: Multiple Indicator Cluster Surveys Data Processing Workshop SPSS general commands Overview MICS Data Processing Workshop.

Example on how to merge hh.sav onto a wm.sav

• Select the key variables:

Page 36: Multiple Indicator Cluster Surveys Data Processing Workshop SPSS general commands Overview MICS Data Processing Workshop.

Example on how to merge hh.sav onto a wm.sav

• SPSS will give you a warning regarding sorted key variables. Make sure both files were sorted in ascending order before trying to do a file merge.

Page 37: Multiple Indicator Cluster Surveys Data Processing Workshop SPSS general commands Overview MICS Data Processing Workshop.

Example on how to merge hh.sav onto a wm.sav

* open the women file.get file ="wm.sav“. * sort cases by ID variables.sort cases HH1 HH2 LN. save outfile = "wm.sav". * open the household file.get file ="hh.sav". * sort cases by ID variables.sort cases HH1 HH2. save outfile = "hh.sav".

 * merge the household data file onto the women file.

match files  /file = "wm.sav"  /table = 'hh.sav'  /by HH1 HH2 . *save the women's file.save outfile = 'wm.sav'.

Page 38: Multiple Indicator Cluster Surveys Data Processing Workshop SPSS general commands Overview MICS Data Processing Workshop.

Aggregate data

• Aggregate data aggregates groups of cases in the active dataset into single cases and creates a new, aggregated file or creates new variables in the active dataset that contain aggregated data

Page 39: Multiple Indicator Cluster Surveys Data Processing Workshop SPSS general commands Overview MICS Data Processing Workshop.

Aggregate data

• Cases are aggregated based on the value of zero or more break (grouping) variables

• If no break variables are specified, then the entire dataset is a single break group

Page 40: Multiple Indicator Cluster Surveys Data Processing Workshop SPSS general commands Overview MICS Data Processing Workshop.

Aggregate data

EXAMPLEAGGREGATE  /OUTFILE=‘tmp1.sav'  /BREAK=HH1 HH2  /hhmem=N(HL1).• AGGREGATE creates a new SPSS Statistics data file, tmp1.sav, that contains 

two break variables (cluster and household number) and new aggregate variables. 

• BREAK specifies cluster and household numbers as the break variables. • One aggregated variables is created: hhmem contains total number of 

household members in each household.

Page 41: Multiple Indicator Cluster Surveys Data Processing Workshop SPSS general commands Overview MICS Data Processing Workshop.

Creating tables using SPSS CTABLES command

• The Custom Tables procedure produces tables in one, two, or three dimensions 

• Command provides a lot of flexibility for organizing and displaying the contents

Page 42: Multiple Indicator Cluster Surveys Data Processing Workshop SPSS general commands Overview MICS Data Processing Workshop.

Creating tables using SPSS CTABLES command

• The Custom Tables procedure produces tables in one, two, or three dimensions 

• Command provides a lot of flexibility for organizing and displaying the contents

• Syntax for the CTABLES command can be generated from the Custom Tables dialog

Page 43: Multiple Indicator Cluster Surveys Data Processing Workshop SPSS general commands Overview MICS Data Processing Workshop.

Creating tables using CTABLES command

CTABLES/FORMAT EMPTY=ZERO {BLANK }{'chars'} /TABLE rows BY columns BY layers/SLABELS POSITION= {COLUMN} VISIBLE= {YES}                                        {ROW }                       {NO }                                       {LAYER }/TITLES CAPTION= ['text' 'text'...]      CORNER= ['text' 'text'...]       TITLE= ['text' 'text'...] 

 

Page 44: Multiple Indicator Cluster Surveys Data Processing Workshop SPSS general commands Overview MICS Data Processing Workshop.

CTABLE Command Example

ctables  /vlabels variables = tot2     display = none  /table hh7 [c] + hh6[c] + mslbrthr [c] +  welevel [c] + tot1[c] by  ebrf[s][mean,'',f5.1]+ tot2[c][count,'',f5.0] /slabels position = column visable = no  /categories var=all empty=exclude missing=exclude  /title title="Table NU.2: Initial breastfeeding" "Percentage of last-born children in the 2 years preceding the survey who were ever breastfed,  percentage who were breastfed within one hour of birth and within one day of birth, and percentage who received a prelacteal feed, " + surveyname  caption="[1] MICS indicator 2.4