Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: RE: tab

From   "Nick Cox" <>
To   <>
Subject   RE: st: RE: tab
Date   Thu, 11 Dec 2003 17:28:02 -0000


. tab rep78, subpop(foreign) 
. tab rep78 if !foreign 

is a way of getting something like 

. bysort foreign: tab rep78

_and_ also getting explicit zeros. 

However, that appears to hinge on a quirk of those variables, 
i.e. the fact that _all_ the values of -rep78- occur for -foreign 
== 0-. 

To expand on Michael's point, for two categories, 
you'd usually need something like 

gen domestic = !foreign
tab rep78, subpop(foreign)
tab rep78, subpop(domestic) 

In general, you need a dummy for 
each category -- and you can get them as a side-effect 
of -tabulate- -- but the display wouldn't be very attractive in 
any case. 

No doubt, -, subpop()- solves the problem it was designed 
to solve, but it doesn't really extend easily to the problem 
I have in mind, wanting explicit zeros in each case. 


Michael Blasnik
> tab rep78, subpop(foreign)
> will do it directly.  It isn't always as convenient, 
> sometimes you need to
> create a dummy variable for your subpop to get exactly what 
> you want.
> > Thanks for the reference to -, subpop()- which
> > somehow has never registered with me; indeed
> > I don't think I ever understood it.
> >
> > Here is the sort of example I had in mind. Some
> > people would like explicit zeros in the case
> > of rep78 == 1, 2 & foreign == 1. Can -, subpop()-
> > help here, directly, without changing the dataset?
> >
> > (This was one motivation for writing -tabcount-,
> > now on SSC. I thought that such tables should be
> > possible on the fly, so far as the user is
> > concerned.)
> >

*   For searches and help try:

© Copyright 1996–2023 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index