230 likes | 316 Views
SPSS Tutorial 101: Import, Merge and Save Data Sets. Dr. Daisy Dai Department of Medical Research. Example: CDC Survey Data. An allergy survey was conducted in 2005 and 2006 to children more than 1 year old.
E N D
SPSS Tutorial 101: Import, Merge and Save Data Sets Dr. Daisy Dai Department of Medical Research
Example: CDC Survey Data • 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.
Tasks • Import these two SAS data files to SPSS and save them as SPSS data file. • Sort each data set by study ID. • Merge allergy variables and demographic variables. • Save new data set as SPSS data file.
Log in SPSS • CMH offers server version SPSS 18. Any employee can log in SPSS from your employee account. • Go to Start ->Program ->Accessories -> Remote Desktop Connection
Log in SPSS • In the prompted connection window, enter cmhterm. • Click Connect.
Log in SPSS • In the Log On Window, enter your cmh user name and password. • Choose log on to CMH • Click OK.
Task 1: Import Data • We need to import two data sets to SPSS. • Allergy qustionaire: aqq_d.xpt (xpt is sas export file) • 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.
Task 1: Import Data • Double click spss 18 icon on the screen. • In the task wizard, click Open an existing source. • Click OK.
Task 1: Import Data • Just in case wizard does not prompt, you can go to file -> Open -> Data
Task 1: Import Data • Select the folder. • Choose agg_d file. • Select xpt format. • 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.
Task 1: Import Data • Now the data is open. • You can see the data in “data View” tab.
Task 1: Import Data • The data structure, variable name, label, etc. are in “Variable View” tab.
Task 2: Sort Data • Variable to be sort: SEQN, that is, Respondent sequence number.
Task 2: Sort Data • Go to Data and select Sort Cases. • On Sort Cases page, select the variable, Respondent sequence number. • Click on right arrow. • Choose Ascending or Descending. • Click OK.
Practice • Now let repeat this process by doing the following: • Open the demographic data, demo_d.xpt. • Sort the data by variable, Respondent Sequence Number.
Task 3: Merge Two Data Sets • Two data sets need to be linked by key variables. • 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. • Both data sets needs to be sorted by the key variable.
Task 3: Merge Two Data Sets • Under any data set, go to Data -> Merge File -> Add Variables
Task 3: Merge Two Data Sets • Choose the other data to add on. • Note, this page will look different in SPSS 18. By all means, choose the other data set.
Task 4: Save the New Data • Go to File -> Save As… • Select the folder. • Create new file, MergedData. • Choose SPSS data format. • Click Save.
Task 4: Save the New Data • Go to Data -> Merge File -> Add Variables