Beginner's Course for Biostatistics using SPSS and Excel
Size: 1.58 MB
Language: en
Added: Jan 28, 2018
Slides: 26 pages
Slide Content
Data Entry in Excel and SPSS + Basic Data manipulation Dhritiman Chakrabarti Assistant Professor, Dept of Neuroanaesthesiology and Neurocritical Care, NIMHANS, Bangalore
SPSS Windows has 3 windows: Data Editor Syntax Editor , which displays syntax files Viewer or Draft Viewer which displays the output files The Data Editor has two parts: Data View window , which displays data from the active file in spreadsheet format Variable View window , which displays metadata or information about the data in the active file, such as variable names and labels, value labels, formats, and missing value indicators.
SPSS Data View
SPSS Variable View
1.2 Data Entry into SPSS There are 2 ways to enter data into SPSS: 1. Directly enter in to SPSS by typing in Data View 2. Enter into other database software such as Excel then import into SPSS Let’s start with the second option, using data in Excel.
What you shouldn’t do – A statistician’s Hell
7 What you should do – A statistician’s Heaven..
8 Give each variable a valid name (8 characters or less with no spaces or punctuation, beginning with a letter not a numeric number). Short, easy to remember word names. Avoid the following variable names: TEST, ALL, BY, EQ, GE, GT, LE, LT, NE, NOT, OR, TO, WITH. These are used in the SPSS syntax and if they were permitted, the software would not be able to distinguish between a command and a variable. Each variable name must be unique; duplication is not allowed. Variable names are not case sensitive. The names NEWVAR, NewVar , and newvar are all considered identical. First row is always Variable name . Second row onwards always contains the patient/sample. General guidelines for data entry into Excel 2. Encode categorical variables - Convert letters and words to numbers. 3. Avoid mixing symbols with data . Convert them to numbers. 4. Give each patient a unique, sequential case number (ID) . Place this ID number in the first column on the left
9 5. Each variable should be in its own column . Avoid this: Animal Control1 Control2 Experiment1 Experiment2 Change to: Animal Group 1 0 2 0 3 1 4 1 * It is recommended to use 0/1 for 2 groups with 0 as a reference group. * Do not combine variables in one column All data for a project should be in one spreadsheet . Do not include graphs or summary statistics in the spreadsheet – Only raw data.
10 8. However when data are repeatedly collected over a patient, it’s recommended to have patient-day observation on a simple line to ease data management. SPSS has a nice feature to convert from the longitudinal format (Long format) to horizontal format (Wide format) – Data Restructuring . When the number of repeats are few 2 or 3, horizontal format may be preferred for simplicity. Date ID SYSBP 1/2/2005 1 130 1/3/2005 1 120 1/4/2005 1 120 3/1/2005 2 110 3/2/2005 2 140 Longitudinal data entry ID SYSBP1 SYSBP2 SYSBP3 1 130 120 120 2 110 140 Horizontal data entry 7. Each patient should be entered on a single line or row. 9 . For yes/no questions, enter “0” for no and “1” for yes . Do not leave blanks for no. Do not enter “?”, “*”, or “NA” for missing data because this indicates to the statistical program than the variable is a string variable. String variables cannot be used for any arithmetic computation.
11 Entering Date in Excel. In Excel,go to: Format, Cells, select Date under Category, Choose Type for a format you like
12 Entering Time in Excel. In Excel, go to: Format, Cells, select Time under Category, Choose Type for a format you like
13 Entering Date / Time in Excel. In Excel, go to: Format, Cells, select Time under Category, Choose Data/Time format
14 Entering Date, Time in SPSS In SPSS, open Variable View, Click Type for the variable you want to Assign date format, click on Date, and select a format of your choice.
15 Importing data from Excel spreadsheet into SPSS. In SPSS, go to: File, Open, Data Select Type of file (for example, Excel) you want to open Select File name you want to open
Data Cleaning in SPSS 1. Re-coding existing variables 2. Creating new variables 3. Creating new variable from existing variables 4. Data labeling and formatting
17 Data cleaning in SPSS (1): Recoding existing variables (1) Old New ID Group Group 1 A 0 2 A 0 3 B 1 4 B 1 We want to use numeric coding for group instead of A and B.
18 Data cleaning in SPSS (2): Recoding existing variables (2) From SPSS dialog box, go to: Transform Recode Into Same variables (better to recode into different variable)
19 1. Select Group from the variable box into String Variables box 2. Click on Old and new Values to proceed Data cleaning in SPSS (1): Recoding existing variables (3)
20 1. Type the old value and the new value you want to convert into 2. Click on Add (To remove, or change, click on Change or Remove) 3. Type all values in the Old New box, then click Continue 4. Click OK to execute the commands. Data cleaning in SPSS (1): Recoding existing variables (4)
21 Data Cleaning in SPSS (2) Creating a new variable for Diastolic blood pressure ( DiasBP ): In SPSS, go to Variable View, Then type DiasBP at the last row under Name Go back to Data View and directly type diastolic blood pressure to separate from SysBP .
Data Cleaning in SPSS (3) Computing New variable from Existing variable(s) Transform Compute Variable this window (Computing MAPB from SBPB And DBPB
23 HT 61.00 68.00 47.00 66.00 72.00 67.00 72.00 72.00 66.00 60.00 61.00 59.00 73.00 65.00 71.00 68.00 69.00 66.00 66.00 68.00 Data Cleaning in SPSS (4): Data labeling and formatting (1) Specifying Type of Variable
24 Data Labeling Data Cleaning in SPSS (4): Data labeling and formatting (2)
25 Variable Formatting – For Categorical variables Data Cleaning in SPSS (4): Data labeling and formatting (3)
26 Data Cleaning in SPSS (4): Data labeling and formatting (5) Measurement category – Interval (Scale); Ordinal; Nominal