Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

# RE: Antwort: st: RE: table weights

 From Nick Cox To "'statalist@hsphsun2.harvard.edu'" Subject RE: Antwort: st: RE: table weights Date Fri, 20 May 2011 12:57:23 +0100

```I've restored the original exchange which helps understand my suggestion. You deleted it unnecessarily.

-tabdisp- circumstantial? I think you mean some quite different word.

That said, here is a stupid example to illustrate what I meant.

. sysuse auto, clear

. table fore rep78 [pw=length], c(mean mpg)

-------------------------------------------------------
|             Repair Record 1978
Car type |       1        2        3        4        5
----------+--------------------------------------------
Domestic | 20.8571  18.9404  18.7088  17.9804  31.9625
Foreign |                    23.218  24.7492  25.8125
-------------------------------------------------------

. bysort foreign rep78 : gen n = _N

. table fore rep78 [pw=length], c(mean mpg min n)

-------------------------------------------------------
|             Repair Record 1978
Car type |       1        2        3        4        5
----------+--------------------------------------------
Domestic | 20.8571  18.9404  18.7088  17.9804  31.9625
|       2        8       27        9        2
|
Foreign |                    23.218  24.7492  25.8125
|                         3        9        9
-------------------------------------------------------

The trick is this:

1. The created variable -n- is actually a constant within groups of -foreign rep78-.

2. Specifying the minimum (or the maximum) is a way to avoid the pweights being applied.

(I don't get your distinction between n and frequency, but the trick remains valid for any other variable constant within groups, so far as I can see.)

Nick
n.j.cox@durham.ac.uk

Denise Sengül

Thanks for replying Nick. But I don't really get what you mean.
-tabdisp- is way too circumstantial in my case.
I've got tables of the form
table var1 var2 [pweight=wei], c(mean var3)
So now I'm trying to add unweighted n's (not frequencies, got it wrong)
I don't really know what you mean by "put unweighted frequencies in
another variable". Since I want the n's to be displayed for each group in
the table, that doesn't really make sense in my head. But please correct
me.

Nick Cox

Put the unweighted frequencies in another variable and then have one of your statistics something like "min freqname". My guess is that the minimum of those frequencies is invariant under pweighting.

Alternatively, switch to -tabdisp- where you have more control.

Denise Sengül

does anyone know how to get pweighted means but unweighted frequencies
together in one table (produced with 'table')? I ideally want separate
columns, one of them containing the frequencies, the other one containing
the means.

*
*   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/
```