1 SPSS Tutorial 101: Import, Merge and Save Data Sets Dr. Daisy Dai Department of Medical Research
2 Example: CDC Survey Data An allergy survey was conducted in 2005 and 2006 to children more than 1 year old. An allergy survey was conducted in 2005 and 2006 to children more than 1 year old. Two data sets, allergy questionnaire and demographic information, are saved in sas export format. Two data sets, allergy questionnaire and demographic information, are saved in sas export format.
3 Tasks Import these two SAS data files to SPSS and save them as SPSS data file. Import these two SAS data files to SPSS and save them as SPSS data file. Sort each data set by study ID. Sort each data set by study ID. Merge allergy variables and demographic variables. Merge allergy variables and demographic variables. Save new data set as SPSS data file. Save new data set as SPSS data file.
4 Log in SPSS CMH offers server version SPSS 18. Any employee can log in SPSS from your employee account. CMH offers server version SPSS 18. Any employee can log in SPSS from your employee account. Go to Start Go to Start ->Program ->Program ->Accessories ->Accessories -> Remote Desktop Connection
5 Log in SPSS In the prompted connection window, enter cmhterm. In the prompted connection window, enter cmhterm. Click Connect. Click Connect.
6 Log in SPSS In the Log On Window, enter your cmh user name and password. In the Log On Window, enter your cmh user name and password. Choose log on to CMH Choose log on to CMH Click OK. Click OK.
7 Task 1: Import Data We need to import two data sets to SPSS. We need to import two data sets to SPSS. Allergy qustionaire: aqq_d.xpt (xpt is sas export file) Allergy qustionaire: aqq_d.xpt (xpt is sas export file) Demographic information: demo_d.xpt Demographic information: demo_d.xpt Please note that SPSS is on server and data must be saved in shared drive such as u drive or w drive. You will not be able to find the file in SPSS if you save them on your local disk. Please note that SPSS is on server and data must be saved in shared drive such as u drive or w drive. You will not be able to find the file in SPSS if you save them on your local disk.
8 Task 1: Import Data Double click spss 18 icon on the screen. Double click spss 18 icon on the screen. In the task wizard, click Open an existing source. In the task wizard, click Open an existing source. Click OK. Click OK.
9 Task 1: Import Data Just in case wizard does not prompt, you can go to file Just in case wizard does not prompt, you can go to file -> Open -> Data
10 Task 1: Import Data Select the folder. Select the folder. Choose agg_d file. Choose agg_d file. Select xpt format. Select xpt format. Click Open. Click Open. Note: SPSS is compatible with other commonly used statistical and data management software packages. Excel, SAS, Access files are all convertible to SPSS. Note: SPSS is compatible with other commonly used statistical and data management software packages. Excel, SAS, Access files are all convertible to SPSS.
11 Task 1: Import Data Now the data is open. Now the data is open. You can see the data in “data View” tab. You can see the data in “data View” tab.
12 Task 1: Import Data The data structure, variable name, label, etc. are in “Variable View” tab. The data structure, variable name, label, etc. are in “Variable View” tab.
13 Task 2: Sort Data Variable to be sort: SEQN, that is, Respondent sequence number. Variable to be sort: SEQN, that is, Respondent sequence number.
14 Task 2: Sort Data Go to Data and select Sort Cases. Go to Data and select Sort Cases. On Sort Cases page, select the variable, Respondent sequence number. On Sort Cases page, select the variable, Respondent sequence number. Click on right arrow. Click on right arrow. Choose Ascending or Descending. Choose Ascending or Descending. Click OK. Click OK.
15 Practice Now let repeat this process by doing the following: Now let repeat this process by doing the following: Open the demographic data, demo_d.xpt. Open the demographic data, demo_d.xpt. Sort the data by variable, Respondent Sequence Number. Sort the data by variable, Respondent Sequence Number.
16 Task 3: Merge Two Data Sets Two data sets need to be linked by key variables. Two data sets need to be linked by key variables. In our case, the key variable is SEQN- Respondent Sequence Number. In our case, the key variable is SEQN- Respondent Sequence Number. Make sure the key variable has the same name and variable type in two data sets. Make sure the key variable has the same name and variable type in two data sets. Both data sets needs to be sorted by the key variable. Both data sets needs to be sorted by the key variable.
17 Task 3: Merge Two Data Sets Under any data set, go to Data Under any data set, go to Data -> Merge File -> Add Variables
18 Task 3: Merge Two Data Sets Choose the other data to add on. Choose the other data to add on. Note, this page will look different in SPSS 18. By all means, choose the other data set. Note, this page will look different in SPSS 18. By all means, choose the other data set.
19 Task 4: Save the New Data Go to File Go to File -> Save As… Select the folder. Select the folder. Create new file, MergedData. Create new file, MergedData. Choose SPSS data format. Choose SPSS data format. Click Save. Click Save.
20 Task 4: Save the New Data Go to Data Go to Data -> Merge File -> Add Variables
21 Thank you!