GAP Toolkit 5 Training in basic drug abuse data management and analysis Training session 7 SPSS: Recode and Compute
Objectives To introduce and demonstrate SPSS tools for recoding variables and creating new variables To introduce and demonstrate the use of SPSS command syntax To introduce and demonstrate Help features in SPSS from a dialogue box
Types of recode A categorical variable into a new set of categories A continuous variable into a categorical variable
Recode approaches Into pre-defined categories of interest Into categories of equal size
Example: pre-defined categories Recode weekly expenditure on drugs into the following categories: –Low expenditure <= £100 a week –High expenditure >= £101 a week
select variable for recoding and click
click here to map old new values
FrequencyPercentValid percent Cumulative percent ValidLow High Total Weekly drug expenditure
Example: quantiles Recode weekly expenditure into the following: –4 categories, each with approximately the same number of cases (quartiles) –10 categories, each with approximately the same number of cases (deciles)
FrequencyPercentValid percentCumulative percent Valid<=£ £91 <= X <= £ £99 <= X <= £ £106 = £ Total NTILES of Expend
FrequencyPercentageValid percentageCumulative percentage Valid Total NTILES of EXPEND
Compute Creates new variables using: –Standard mathematical operators –A full range of functions –Conditional statements
Transform/Compute click here to define variable type
Type and Label
Yexpend=Expend*52
Explore: Yexpend StatisticStd. error Yearly drug expenditureMean % Confidence Interval for Mean Lower Bound Upper Bound % Trimmed Mean Median Variance Std. Deviation Minimum3848 Maximum6032 Range2184 Interquartile Range Skewness Kurtosis Descriptives
Example 2: Age Convert date of birth to age in years
(DATE.DMY(01,01,2002) - dob) / (365.25*24*60*60)
Explore: Age StatisticStd. error AGEMean % Confidence Interval for Mean Lower Bound22.97 Upper Bound % Trimmed Mean25.21 Median22.84 Variance Std. Deviation8.536 Minimum11 Maximum44 Range32 Interquartile Range12.77 Skewness Kurtosis Descriptives
Help Context-sensitive Help: –Right click on any part of a dialogue box to obtain help Dialogue box Help button
Command language Command-line rather than Windows interface More flexible Reusable Saved as text files
Syntax window Enter SPSS commands: –Type directly –Paste from a dialogue box Run SPSS commands Save as a text file
The Paste button click to copy command into Syntax Window
The Run menu
Syntax for Age
Summary Recode: –Into same variable –Into different variable Compute: –Mathematical operators –Functions Dialogue box Help: –Context-sensitive Help –Dialogue box Help button Command language: –Syntax Window –Dialogue box Paste button