|
|
|
||||
|
|
|||||
Let's begin by opening the data file.
File Open select the C: drive, the SPSS folder, and hs0.sav
It is often useful to see information regarding the data file, such as the number of cases and variables, any type of labels, etc.
File Display Data Info... select c:/spss/hs0.sav
Reordering variables in the data file is helpful both for organizational reasons as well as to minimize the amount of scrolling you need to do in order to see the variables that you are working with. We will use the "cut and paste" method of reordering the variables.
highlight id
Edit
Cut
highlight the variable that will appear after the newly-placed variable,
say gender. Highlight gender
Data
Insert variable
Edit
Paste
Adding variable labels is a very useful data management strategy, and we strongly encourage you to take the time to do this when you input a data set or receive a data file.
Click on "Variable View" tab (in the lower left corner) for schtyp, type in the label "The type of school the student attended.".
Now let's add some value labels.
Click "Variable View" tab click on the right side of the value box for gender, enter the value 1 and the label female and click "add", enter the value 2 and the label male and click "add", and then type "gender" for the label
If we click on the "Variable View" tab, we can see that the variable prgtype is a string variable, and this may cause some difficulty when we are using this variable in analyses. So let's create a numeric of this variable.
Transform Automatic recode... select prgtype type in a name for the new variable (prog) and click on the "New Name" button
Add a variable label to the variable that we just created.
Renaming variables is easy.
Click on the "Variable View" tab and change gender to female
Add a variable label and value labels to female.
Suppose that we would like to recode some values of a variable. For example, we might want to change the 5s to missing.
Transform
Recode
Into same variable...
select race
click "Old and New Values" and type in the old value (5) and the
new value, in this case, click on the "System-missing" radio button,
and then click on "Add", then "Continue", then "OK"
There are many ways that you can create a new variable. One way is to use a numeric expression. For example, let's create a variable called total that will be the sum of the reading, writing and math scores.
Transform Compute... type in the name of the new variable, total, (called the "Target Variable") and the numeric expression that will create the variable: read + write + math
Now let's summarize the variable that we have just created.
Analyze Descriptive Statistics Descriptives... select total
We will recode total to become grade as shown below.
Transform
Recode...
Into different variables...
select total as the "input -> output variable"
type grade as the output variable
change
click "old and new values"
click on "range: lowest thru" and type 80 as the value and type 1
as the new value
click on "range" and continue to enter the values according the
table below. For the last category, click on "range: thru highest"
recoding total into grade:
lowest - 80 = 1
80 - 110 = 2
110 - 140 = 3
140 - highest = 4
Finally, let's make z-scores of some of our variables. There are at least two way that you could do this. If you remember the formula for creating z-scores and you know the mean of the variable, you can use the transform -> compute function as we did before. Another way to create the z-scores is shown below.
Analyze
Descriptive Statistics
Descriptives...
select read
click on the box "Save standardized values as variables"
* open the data file. get file "c:\spss\hs0.sav". * using sysfile info to view the properties of the data set. * because we have not listed any variables after the command, spss will show us the * codebook for all of the variables. sysfile info "c:\spss\hs0.sav". file label "high school and beyond, 200 cases". save outfile "c:\spss\hs01.sav". get file "c:\spss\hs01.sav". sysfile info "c:\spss\hs01.sav". * ordering the variables in a way that makes sense. save outfile = "c:\spss\hs01.sav" / keep id gender all. get file "c:\spss\hs01.sav". display variables. * adding variable and value labels to schtyp. variable labels schtyp "the type of school the student attended.". value labels schtyp 1 "public" 2 "private". display dictionary /var = schtyp. list schtyp /cases from 1 to 20. * changing prgtype from a string to a numeric variable (called prog). autorecode prgtype /into prog. variable labels prog "the type of program in which the student was enrolled.". display dictionary /var = prog. list prog /cases from 1 to 10. * renaming the variable gender to female and adding a variable label and value labels. rename variables (gender = female). variable labels female "the gender of the student.". value labels female 1 "female" 0 "male". display dictionary /var = female. list female /cases from 1 to 10. * recoding race = 5 to missing. frequencies var = race. recode race (5 = sysmis). frequencies var = race. * adding notes to the data set and viewing the notes. document the variable gender was renamed to female. document values of race coded as 5 were recoded to be missing. display document. * creating a variable that is a total of some of the test scores. compute total = read + write + math. variable labels total "the total of the reading, writing and social studies scores.". summarize var = total. display dictionary /var = total. * assigning some letter grades to these test scores. recode total (0 thru 80=0) (80 thru 110 =1) (110 thru 140=2) (140 thru 170=3) (170 thru 300=4) into grade. execute. value labels grade 0 "f" 1 "d" 2 "c" 3 "b" 4 "a". variable labels grade "these are the combined grades of reading, writing and social studies scores.". display dictionary /var = grade. list read write socst grade /cases from 1 to 10. * there is another way to create variables in spss that uses special functions. descriptives var = read /save. summarize var = zread. list read zread /cases from 1 to 10. save outfile "c:\spss\hs1.sav".
UCLA Researchers are invited to our Statistical Consulting Services
We recommend others to our list of Other Resources for Statistical Computing Help
These pages are Copyrighted (c) by UCLA Academic Technology Services