# Jeromy Anglim's Blog: Psychology and Statistics

## Sunday, October 4, 2009

### Producing a Table of Item Descriptive Statistics

The following post sets out how to present a table of descriptive statistics for a set of items using SPSS, Excel, and Word. At the bottom of the post, I've got an example of doing it in R.

The Example:
The example aims to provide descriptive statistics for items on a scale looking at attitudes towards learning at
university.
Finney, S. J., Pieper, S. L., & Barron, K. E. (2004). Examining the psychometric properties of the Achievement Goal Questionnaire in a general academic context. Educational and Psychological Measurement, 64, 365-382.

The aim is to provide means and percentages of participants choosing specific response ranges. This format is is similar to that used at my own university when reporting quality of teaching scores. A table is provided where each row contains a survey question and columns are provided for the mean, and percentage of respondents agreeing (options 4 or 5) and disagreeing (options 1 or 2) with each item. A useful property of providing both the mean and the percentages is that each provides a useful way of thinking about the overall pattern of responses. Percentages are often easier to interpret intuitively.

The example has 12 items with variable names attitude1 to attitude12. Each item is on a 7 point scale.
This is a subset of the data as viewed from SPSS:

Steps:
1. calculate variables to represent groups of response options. My aim is to report the percentage of respondents reporting 1 to 3; 4; and 5 to 7.
* Attitude Measure.
DO REPEAT  x = attitude1 to attitude12/
xLOW = attitudeLOW1 to attitudeLOW12.
COMPUTE  xLOW = 0.
IF ( x = 1 OR x = 2  OR x = 3)  xLOW = 1.
END REPEAT.

DO REPEAT  x = attitude1 to attitude12/
xMID = attitudeMID1 to attitudeMID12.
COMPUTE  xMID = 0.
IF ( x = 4)  xMID = 1.
END REPEAT.

DO REPEAT  x = attitude1 to attitude12/
xHIGH = attitudeHIGH1 to attitudeHIGH12.
COMPUTE  xHIGH = 0.
IF ( x = 5 OR x = 6  OR x = 7)  xHIGH = 1.
END REPEAT.
EXECUTE.


The syntax above should be run. It will create three new sets of variables with a value of 1 if the respondent answered one of the target values (e.g., 1, 2, or 3 for low) and 0 otherwise. To learn more about DO repeat in SPSS, check out some of these links (University of Washington, SPSS, UCLA).

To modify the above syntax for your own needs, alter the variable names and numbers. And alter the focal response values (e.g., for a five point scale, you might have x = 1 OR x = 2 for low, 3 for mid, and 4 OR 5 for high).

2. Get the mean and percentage in each category for each item.
DESCRIPTIVES VARIABLES=attitude1 to attitude12
/STATISTICS=MEAN.
DESCRIPTIVES VARIABLES=attitudeLOW1 to attitudeLOW12
/STATISTICS=MEAN.
DESCRIPTIVES VARIABLES=attitudeMID1 to attitudeMID12
/STATISTICS=MEAN.
DESCRIPTIVES VARIABLES=attitudeHIGH1 to attitudeHIGH12
/STATISTICS=MEAN.


The above syntax will provide the output. You could alternatively use the menus and go to Analyse - Descriptives - Descriptive Statistics.

3. Set up the table in Excel
(a) Paste in the above tables from SPSS into an Excel worksheet. Clear the formatting from these. Or paste special (unicode)

(b) Add Item Number and Item Text (and optionally the factor that the item belongs to).

(c) Add Column names to columns that will be retained in the final table

(d) Delete superfluous columns of output (control+ space highlights a column; control + minus deletes a column)

(e) tidy up number formatting
e.g., for the means, control+1 brings up cell formatting; then numbers 2 decimal places was selected for the mean; percentage with 0 or 1 decimal place might be useful for the categories.

(e) Highlight table and copy and paste into Word

(f) Format in Word (e.g., add lines, change font, change alignment, change row and column heights, etc.)

And here's how you might do it in R:
tableOfItemDescriptives <- function(x,
lowRange = 1:3, midRange = 4, highRange = 5:7,
file = "clipboard-128") {

meanOfX <- mean(x,na.rm = TRUE)
lowXPercent <- sapply(x, function(X)
mean(X %in% lowRange, na.rm = TRUE))
midXPercent <- sapply(x, function(X)
mean(X %in% midRange, na.rm = TRUE))
highXPercent <- sapply(x, function(X)
mean(X %in% highRange, na.rm = TRUE))

resultsTable <- data.frame(mean = meanOfX,
low = lowXPercent,
mid = midXPercent,
high = highXPercent)

write.table(resultsTable, file = file,
sep ="\t", row.names = FALSE)

resultsTable
}

items <- c("attitude1", "attitude2", "attitude3", "attitude4", "attitude5",
"attitude6", "attitude7", "attitude8", "attitude9", "attitude10",
"attitude11", "attitude12")
x <- na.omit(dCasesForExport[items])
tableOfItemDescriptives(x=x)


#### 1 comment:

1. In SPSS 16 you can do it very easily using Custom Tables and inserting subtotals