160 likes | 396 Views
MICS Data Processing Workshop. Recoding in SPSS. Secondary Data Processing Flow. Export Data from CSPRO. Import Data into SPSS. Recode Variables. Add Sample Weights, Wealth Index and GPS Data. Run Tables. SPSS Working Directory. Right-click on SPSS icon Select Properties
E N D
MICS Data Processing Workshop Recoding in SPSS
Secondary Data Processing Flow Export Data from CSPRO Import Data into SPSS Recode Variables Add Sample Weights, Wealth Index and GPS Data Run Tables
SPSS Working Directory • Right-click on SPSS icon • Select Properties • Click on Start-in box • Type in C:\RECODING
Analysis Files • 4 types of analysis files\cases • Households • Household members • Women • Children
Program Names • MAKEWM • Creates women’s analysis file • MAKECH • Creates children’s analysis file
Program Functions • Programs add needed variables • 2 sources of new variables • Existing variables that are recoded • Age age in 5-year groups • Combinations of existing variables • Level and grade of education years of education
Recoding Variables • Some variables recoded in MAKE**.SPS • Important variables (e.g., age) • Frequently used variables • Some variables are recoded in tab programs • Variables used in only a few tables • Unusual recoding of a variable
Opening and Saving Files • To open a data file get file = ‘filename.sav’. • To save a data file save outfile = ‘filename.sav’.
The recode Command • To recode a variable recode HL5 (lo thru 70 = copy) (71 thru 96 = 70) (98,99 = 99) into memage. • Useful keywords • lo and hi • copy • sysmis • else
The compute command • Creates a new variable • compute newvar = 1. • The compute command has built-in functions • compute newvar = trunc(oldvar). • compute newvar = rnd(oldvar).
Defining Variable and Value Labels • To define a variable label variable label memage "Age". • To define a value label set value label memage 70 ”70+" 99 ”Missing/DK“. • Defines value labels for unusual values • Values 0-70 will be labeled using their actual value
The if Command compute fuelelec = 0. if (hc6 = 1) fuelelec = 1. variable label fuelelec 'Household fuel type: electricity'. value label fuelelec 0 'No' 1 'Yes'.
The do if Command *total children ever born. do if (CM1 = 1). compute ceb = CM9. else. compute ceb = 0. end if.
Selecting Cases to Process • The select command select if (HL5 >= 5 and HL5 <= 14). • Deletes unselected cases from memory • The filter command filter by CM9. filter off. • Selects cases for whom filter variable > 0 • Unselected cases are ignored by subsequent commands
Other Useful Commands • To set a variable’s format format memage(f5.0). • To define missing values missing values wdob (9999). • To count occurrences of a value count ways = v1 v2 v3 (1).
Using the Paste Option to Write Code • Set up the command using SPSS’s menu system • Click on the “Paste” button • SPSS will “paste” the code necessary to execute the command in the active syntax window • This is a great way to learn SPSS’s language