|
|
|
||||
|
|
|||||
Let's pretend that we are working on our honors thesis and that we want to study just "good readers", those with reading scores 60 or higher. We will open the file and then "select cases" to include the students with reading scores of 60 or higher.
File Open Data choose c:\spss\hs1.sav
Data
Select Cases
click if "condition is satisfied" and click "if" box
read >= 60
Continue
choose "Unselected Cases are" Deleted
Notice that the undesired cases have now been deleted. Now we will save our data.
File Save as c:\spss\honors\hsgoodread.sav
We want to keep just some variables, including id female read and write. We keep these variables in the same procedure that we use to save the data file.
File
Save as
choose c:\spss\hskept.sav
variables
drop all
click check boxes next to id, female, read, write
Save
Notice you can also choose keep all if that is more helpful to you.
Let's suppose we are working on our masters thesis. The data are located in a folder called c:\spss\masters and there are two files in this folder, one for the males (hsmale.sav) and one for the females (hsfemale.sav). We would like to combine these files.
File Open Data c:\spss\masters\hsmale.sav
Analyze Descriptive Statistics Frequencies select female
Data
Merge Files
Add Cases
choose c:\spss\masters\hsfemale.sav
OK
File Save As c:\spss\masters\hsmasters.sav
Now let's suppose that we are working on our dissertation. The data are in a folder called c:\spss\diss and there are two files in this folder, one with the demographic information (hsdem.sav) and one with the test scores (hstest.sav). We would like to match merge these files based on id. Before we can match merge these files, we need to open each file, sort it on id, and then save the sorted file.
File Open Data c:\spss\diss\hsdem.sav
Data Sort Cases choose id
File Save As c:\spss\diss\hsdem.sav
Now that we have sorted and saved the first file (hsdem.sav), we will do the same thing
for the second file (hstest.sav).
File Open Data c:\spss\diss\hstest.sav
Data Sort Cases choose id
File Save As c:\spss\diss\hstest.sav
Finally, we will open the first file (hsdem.sav) and merge it with the second file (hstest.sav). We will save the merged data file with the name hsdiss.sav.
File Open Data c:\spss\diss\hsdem.sav
Data
Merge Files
Add Variables
choose c:\spss\diss\hstest.sav
click "match cases on key variable"
move id as key variable
click "Indicate case as source variable" (name it fromtest).
File Save As c:\spss\diss\hsdiss.sav
* working on honors thesis. * want to make a subset just keeping those who have read >= 60. get file "c:\spss\hs1.sav". * assuming we already have a folder called "c:\spss\honors". select if read >=60. descriptives /var=read. save outfile "c:\spss\honors\hsgoodread.sav". * pretend we have 2000 variables and we want to keep just some of the variables. * we want to keep just the variables id female read write. save outfile = "c:\spss\honors\hskept.sav" /keep=id female read write. display names. get file "c:\spss\honors\hskept.sav". display names. * extra example not in point and click. * we want to drop just the variables ses and prog. get file "c:\spss\honors\hsgoodread.sav". save outfile "c:\spss\honors\hsdropped.sav" /drop=ses prog. display names. get file "c:\spss\honors\hsdropped.sav". display names. * have one file with males, females in another file and need to "append" the files. get file "c:\spss\masters\hsmale.sav". freq /var=female. add files /file=* /file="c:\spss\masters\hsfemale.sav". freq /var=female. save outfile "c:\spss\masters\hsmasters.sav". * one file has demographic scores, the other has test scores and we want to "match merge" the files. get file "c:\spss\diss\hsdem.sav". list cases from 1 to 10. sort cases by id. save outfile "c:\spss\diss\hsdem.sav". get file "c:\spss\diss\hstest.sav". list cases from 1 to 10. sort cases by id. save outfile "c:\spss\diss\hstest.sav". get file "c:\spss\diss\hsdem.sav". match files /file=* /in=fromdem /file="c:\spss\diss\hstest.sav" /in=fromtest /by id. list cases from 1 to 10. list variables id fromdem fromtest. crosstab /tables=fromdem by fromtest. save outfile "c:\spss\diss\hsdiss.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