180 likes | 368 Views
Data Manipulation II Transforming, Recoding, and Splitting/Grouping. SPSS Training Thomas V. Joshua , MS July 2012. College of Nursing. Lecture Overview. Transformation (computing) of Data Recoding Splitting/Grouping. Transformation (computing) of Data.
E N D
Data Manipulation IITransforming, Recoding, and Splitting/Grouping SPSS Training Thomas V. Joshua, MS July 2012 College of Nursing
Lecture Overview • Transformation (computing) of Data • Recoding • Splitting/Grouping
Transformation (computing) of Data • SPSS has very powerful capabilities for creating new variables as a function of existing variables, for example • To create averages of existing variables • To rescale existing variables • To compute difference scores by subtracting one variable from another
Computing A New Variable • Target Variable - new variable name. • Numeric Expression - defining the new variable, essentially giving SPSS a formula. • The variables in the Numeric Expression need to be either existing variables or numbers. • Specify the Type and Label for the new Variable.
Conditionally Computing A New Variable • Variables can also be computed conditionally. For instance, if in the above example, you were only interested in the change in salaries for people who began working for the company within the last six years. • If… button (optional case selection condition)
Transforming An Existing Variable • For example, the variable jobtime represents months of experience on the job, but we may wish to analyze data in terms of years on the job • Give a new variable name or keep the existing name for the Target Variable
Recoding Variables • Another way to modify the values of existing variables in your dataset. In the Data Editor: Transform -> Recode • Into Same Variables option - changes the values of the existing variables. • Into Different Variables option - create a new variable with the recoded values. (not overwrite your original data) • Both options are essentially the same, except that recoding into a different variable requires you to supply a new variable name.
Recoding Variables Categories to Categories For example, the variable jobcat codes an employee's status in three categories, but for a particular analysis you may want to combine two of these classifications into a single category. The original coding was • Clerical = 1 -> 1 • Custodial = 2 -> 2 • Manager = 3 -> 2
Recoding Variables Input variable -> Output variable -> Change bottom -> Define the old and new values
With System-missing selected • Without System-missing selected
Recoding VariablesNumeric to Categories • Recode the continuous variable to the categorical variable • Useful in cross-tabulation • Group ranges of the variable into categories For example, we need to code an employee's current salary into two categories as the following Less than or equal to $27,000 (Low) -> 1 More than $27,000 (High) -> 2
Where is the value 27,000? • How about if there are more than 2 groups?
Splitting/Grouping • In some situations, you may want to perform the same analysis on different groups within the same dataset. • Analyses such as these can be conducted by first selecting the Split File function from the Data menu in the Data Editor: Data -> Split File...
Splitting/Grouping If you select the option to "Sort the file by grouping variable," SPSS will run the "Sort File" command in the background. Because the split file command remains in effect indefinitely, you should reset this option when you no longer want a split file analysis.
Splitting/Grouping • The Compare groups and Organize output by groups result in the same values in the output, regardless of the analysis being performed, but they differ in the way in which the output is presented. • Compare groups SORT CASES BY gender . SPLIT FILE LAYERED BY gender .
Splitting/Grouping SORT CASES BY gender . SPLIT FILE SEPARATE BY gender . • Organize output by groups Gender = Female Gender = Male