Labels

Learn the powerful enterprise adaptable database:

Getting Started With ADABAS & Natural

Monday, January 28, 2013

SPSS - Preparing the data file


Practical Exercises



Survey4ED.sav

This is a real data file, condensed from a study that was conducted by my Graduate Diploma in Educational Psychology students. The study was designed to explore the factors that impact on respondents’ psychological adjustment and wellbeing. The survey contained a variety of validated scales measuring constructs that the extensive literature on stress and coping suggest influence people’s experience of stress. The scales measured self-esteem, optimism, perceptions of control, perceived stress, positive and negative affect, and life satisfaction. A scale was also included that measured people’s tendency to present themselves in a favourable or socially desirable manner. The survey was distributed to members of the general public in Melbourne, Australia and surrounding districts. The final sample size was 439, consisting of 42 per cent males and 58 per cent females, with ages ranging from 18 to 82 (mean=37.4).

Error4ED.sav

The data in this file has been modified from the survey4ED.zip file to incorporate some deliberate errors to be identified using the procedures covered in Chapter 5. For information on the variables etc. see details on survey4ED.zip.


----------


MERGE FILES

There are times when it is necessary to merge different data files. SPSS allows you to merge files by adding additional cases at the end of your file, or to merge additional variables for each of the cases in an existing data file (e.g. when Time 2 data becomes available). This second option is also useful when you have Excel files with information spread across different spreadsheets that need to be merged by ID.

To merge files by adding cases

This procedure will allow you to merge files that have the same variables, but different cases; for example, where the same information is recorded at two different sites (e.g. clinic settings) or entered by two different people. The two files should have the same variable names for the data you wish to merge (although other non-equivalent information can exist in each file).


If the ID numbers used in each file are the same (starting at ID=1, 2, 3), you will need to change the ID numbers in one of the files before merging so that each case is still uniquely identified. To do this, open one of the files, choose Transform from the menu, and then Compute Variable. Type ID in the Target Variable box, and then ID + 1000 in the Numeric Expression box (or some number that is bigger than the number of cases in the file). Click on the OK button, and then on OK in the dialogue box that asks if you wish to change the variable. This will create new ID numbers for this file starting at 1001, 1002 and so on. Note this in your codebook for future reference. Then you are ready to merge the files.


Steps:

1. Open the first fi le that you wish to merge.
2. Go to the Data menu, choose Merge Files and then Add Cases.
3. In the dialogue box, click on An external SPSS data file and choose the file that you wish to merge with. (If your second fi le is already open it will be listed in the top box, An open dataset.)
4. Click on Continue and then on OK. Save the new data file using a different name (File, Save As).

To merge files by adding variables


This option is useful when adding additional information for each case (with the
matching IDs). Each file must start with the ID number.

Steps:

1. Sort each file in ascending order by ID by clicking on the Data menu, choose Sort Cases and choose ID.
2. Go to the Data menu, choose Merge files and then Add Variables.
3. In the dialogue box, click on An external SPSS data file and choose the file that you wish to merge with. (If your second fi le is already open it will be listed in the top box, An open dataset.)
4. In the Excluded variables box, you should see the ID variable listed (because it exists in both data files). (If you have any other variables listed here, you will need to click on the Rename button to change the variable name so that it is unique.)
5. Click on the ID variable, and then on the box Match cases on key variables and on the arrow button to move ID into the Key Variables box. This means that all information will be matched by ID. Click on Continue and then OK.
6. Save your merged fi le under a different name (File, Save As).


USEFUL SPSS FEATURES

There are many useful features of SPSS that can be used to help with analyses, and to save you time and effort. I have highlighted a few of the main ones in the following sections.

Sort the data file

You can ask SPSS to sort your data file according to values on one of your variables (e.g. sex, age).

Steps:
1. Click on the Data menu, choose Sort Cases and specify which variable will be used to sort by. Choose either Ascending or Descending. Click on OK.
2. To return your fi le to its original order repeat the process, asking SPSS to sort the fi le by ID.

Split the data fi le

Sometimes it is necessary to split your file and to repeat analyses for groups (e.g. males and females) separately. This procedure does not physically alter your file in any permanent manner. It is an option you can turn on and off as it suits your purposes. The order in which the cases are displayed in the data file will change, however. You can return the data file to its original order (by ID) by using the Sort Cases command described above.

Steps:
1. Click on the Data menu and choose the Split File option.
2. Click on Compare groups and specify the grouping variable (e.g. sex). Click on OK.


For the analyses that you perform after this split file procedure, the two groups (in this case, males and females) will be analysed separately.

Important: when you have finished the analyses, you need to go back and turn the Split File option off.

Steps:
1. Click on the Data menu and choose the Split File option.
2. Click on the first dot (Analyze all cases, do not create groups). Click on OK.

Select cases
For some analyses, you may wish to select a subset of your sample (e.g. only males).

Steps:
1. Click on the Data menu and choose the Select Cases option.
2. Click on the If condition is satisfied button.
3. Click on the button labelled IF.

4. Choose the variable that defines the group that you are interested in (e.g. sex).
5. Click on the arrow button to move the variable name into the box. Click on the = key from the keypad displayed on the screen.
6. Type in the value that corresponds to the group you are interested in (check with your codebook). For example, males in this sample are coded 1, therefore you would type in 1. The command line should read: sex=1.
7. Click on Continue and then OK.



For the analyses (e.g. correlation) that you perform after this Select Cases procedure, only the group that you selected (e.g. males) will be included.
Important: when you have finished the analyses, you need to go back and turn the Select Cases option off, otherwise it will apply to all analyses conducted.

Steps:
1. Click on the Data menu and choose Select Cases option.
2. Click on the first All cases option. Click on OK.


USING SETS

With large data files, it can be a pain to have to scroll through lots of variable names in SPSS dialogue boxes to reach the ones that you want to analyse. SPSS allows you to define and use ‘sets’ of variables. This is particularly useful in the survey4ED.sav data file, where there are lots of individual items that are added to give total scores, which are located at the end of the file. In the following example, I will establish a set that includes only the demographic variables and the scale totals.

Steps:
1. Click on Utilities from the menu and choose Define Variable Sets.
2. Choose the variables you want in your set from the list. Include ID, the demographic variables (sex through to smoke number), and then all the totals at the end of the data file from Total Optimism onwards. Move these into the Variables in Set box.
3. In the box Set Name, type an appropriate name for your set (e.g. Totals).
4. Click on the Add Set button and then on Close.

To use the sets you have created, you need to activate them.
1. Click on Utilities and on Use Variable Sets.
2. In the list of variable sets, tick the set you have created (Totals) and then go up and untick the ALLVARIABLES option, as this would display all variables. Leave NEWVARIABLES ticked. Click on OK. With the sets activated, only the selected variables will be displayed in the data file and in the dialogue boxes used to conduct statistical analyses.


To turn the option off
1. Click on Utilities and on Use Variable Sets.
2. Tick the ALLVARIABLES option and click OK.

Data file comments
Under the Utilities menu, SPSS provides you with the chance to save descriptive comments with a data fi le.
1. Select Utilities and Data File Comments.
2. Type in your comments, and if you would like them recorded in the
output fi le, click on the option Display comments in output. Comments
are saved with the date they were made.

Display values labels in data fi le
When the data file is displayed in the Data Editor window, the numerical values for all variables are usually shown. If you would like the value labels (e.g. male, female) displayed instead, go to the View menu and choose Value Labels. To turn this option off, go to the View menu and click on Value Labels again to remove the tick.











No comments:

Post a Comment