# GAP Toolkit 5 Training in basic drug abuse data management and analysis Training session 7 SPSS: Recode and Compute.

## Presentation on theme: "GAP Toolkit 5 Training in basic drug abuse data management and analysis Training session 7 SPSS: Recode and Compute."— Presentation transcript:

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 ValidLow3162.0 High1938.0 100.0 Total50100.0 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<=£901224.0 £91 <= X <= £981224.0 48.0 £99 <= X <= £1051326.0 74.0 £106 = £1161326.0 100.0 Total50100.0 NTILES of Expend

FrequencyPercentageValid percentageCumulative percentage Valid1510.0 248.0 18.0 3714.0 32.0 448.0 40.0 548.0 48.0 6612.0 60.0 7510.0 70.0 8510.0 80.0 9612.0 92.0 1048.0 100.0 Total50100.0 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 expenditureMean5062.7277.468 95% Confidence Interval for Mean Lower Bound4907.04 Upper Bound5218.40 5% Trimmed Mean5072.89 Median5148.00 Variance300062.3 Std. Deviation547.779 Minimum3848 Maximum6032 Range2184 Interquartile Range754.00 Skewness-.333.337 Kurtosis-.446.662 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 AGEMean25.431.219 95% Confidence Interval for Mean Lower Bound22.97 Upper Bound27.88 5% Trimmed Mean25.21 Median22.84 Variance72.867 Std. Deviation8.536 Minimum11 Maximum44 Range32 Interquartile Range12.77 Skewness.579.340 Kurtosis-.518.668 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