Discussion about stat consulting, stat packages, applied statistics and data analysis by statistical consultants of Academic Technology Services at UCLA. Please leave your comments or send us email at stattalk at ats.ucla.edu

Thursday, November 30, 2006

Hey, where's the blog???

Okay, okay -- we've been really swamped in consulting. So here's a short item from yesterday to get things rolling. A student from one of the campus administrative offices comes in because she needs do a frequency distribution for items on a campus questionnaire. The catch is, they want the frequency distributions of the items to include zero frequencies, that is, when a response to one of the items is "not very often" but no one selects that response they want the table to show a zero.

This is actually fairly tricky because if no one selects that response the program doesn't "know" that the response even exists. The student's data were in Stata so I did a quick search over the internet using Stata's findit command and found a nifty program by Nick Cox called tabcount. Here's an example of how the command looks.

tabcount item1, v1(1/5)
In this example, item1 is the variable name and v1(1/5) indicates the range of possible response values. This command would have to be repeated 30 times for 30 items each with different ranges of response values.

The tabcount program would work fine for the student, but I though that I could write one that would be easier for the student to use. So, I created tablabel which uses the value labels for each of the items to define the range of values. Here is what the command looked like for the student's data.

tablabel item1-item30
And here's the output from one of the items.
Variable: item4 -- ethnicity

Value Freq Label
1 24 hispanic
2 211 asian
3 0 african-amer
4 143 white

Missing observations: 1

If you would like to try tablabel for yourself just type,

findit tablabel
in the Stata command line and follow the installation instructions. Remember, the variables need to have value labels already defined.

pbe

Contributors