Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Nick Cox <njcoxstata@gmail.com> |
To | statalist@hsphsun2.harvard.edu |
Subject | Re: st: Tabout including all categories |
Date | Fri, 6 Jan 2012 19:13:59 +0000 |
Your question was previously asked, and answered, on Tuesday: http://www.stata.com/statalist/archive/2012-01/msg00090.html (Executive summary: No!) You're getting nowhere fast on this problem, it seems. I looked at it again and suggest this approach: clear set obs 100 label def myval 1 appalling 2 awful 3 average 4 acceptable 5 amusing 6 amazing forval j = 1/3 { gen catvar`j' = ceil(2 * `j' * runiform()^2) label val catvar`j' myval } tab1 catvar* egen year = seq(), from(2001) to(2010) block(10) foreach v of var catvar* { qui labelsof `v' tabcount `v' year, v1(`r(values)') v2(2001/2010) } The first block of lines just sets up a dataset as sandpit. (None of us can see your data.) The crucial new details are -labelsof- (SSC) to get a list of defined labels for a variable and -tabcount- (SSC) to get a twoway table. Whether you can use either of these programs with -tabout- I don't know. Ian Watson, the author of -tabout- (SSC), is currently not a member of Statalist, I believe. -tabout- is an excellent program, but I don't use it. Nick On Fri, Jan 6, 2012 at 5:05 PM, Elizabeth Knaster <ElizabethK@uihi.org> wrote: > Thanks for the reply, Nick. > > Can -groups- be used with -tabout-? From: Nick Cox <njcoxstata@gmail.com> > Expecting -tabout- to know about -fre- just won't work (both SSC). > > One alternative is -groups- (SSC). On 28 Dec 2011, at 17:35, Elizabeth Knaster <ElizabethK@uihi.org> wrote: >> Thanks for your reply. Yes, I meant to say "cells with zero >> frequencies." Any ideas? Nick Cox <njcoxstata@gmail.com> >> Showing zero values is not a problem with any tabulation command. Do >> you mean cells with zero frequencies? On Thu, Dec 22, 2011 at 7:31 PM, Elizabeth Knaster <ElizabethK@uihi.org >>> Hello! I could use some help with tabout: >>> >>> I want to use tabout to produce tables with all categories of a >>> variable, even if the value is equal to zero. I have installed fre >>> from SSC and have successfully used includelabeled, for example, >>> "fre agecat, includelabeled" but I am unable to use >>> "includelabeled" with tabout. Is there a way to incorporate fre and >>> includelabeled in the tabout syntax? Or is there some other way to >>> have tabout display all categories of a variable, including zero? >>> >>> This is the current code I am using, for reference: >>> >>> foreach var0 in sex agecat durdmcat dmtype BMIcat { >>> tabout `var0' year using "AllSitesTrends.xls", append mi c(freq >>> col) f(0 3p) clab(N %) >>> } * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/