Bookmark and Share

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


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: RE: table weights


From   Maarten Buis <[email protected]>
To   [email protected]
Subject   Re: st: RE: table weights
Date   Fri, 20 May 2011 14:07:26 +0200

On Fri, May 20, 2011 at 1:41 PM, Denise Sengül wrote:
> Thanks for replying Nick. But I don't really get what you mean.
> -tabdisp- is way too circumstantial in my case.

If you want a non-standard table than you have to use more general
techniques. The difficulty with that is that the extra flexibility
comes with extra work on your side.

-tabdisp- is a way of displaying the literal content of a dataset as
if it were a table, that is, the contents of the cells is already in
the dataset. You can create such datasets using -collapse- and/or
-contract-. You typically do not want to save such datasets, so you
would do well to precede the whole operation with -preserve- and end
it with -restore-. Anyhow, I would just start simple with only the
means or the frequencies, and after you got that working add the other
statistic. Below is an example to get you started

*---------------- begin example -------------------
sysuse auto, clear

preserve
collapse (mean) mpg, by(foreign rep78)
tempfile tofill
gen byte freq = 0
save `tofill'

sysuse auto, clear
contract foreign rep78
gen byte freq = 1

append using `tofill'

gen stat = cond(freq==1, _freq, mpg)
label define freq 1 "frequency" 0 "mean"
label value freq freq

tabdisp rep78 foreign freq, ///
        cell(stat) format(%9.3g)
restore
*------------------- end example ---------------------
(For more on examples I sent to the Statalist see:
http://www.maartenbuis.nl/example_faq )

Hope this helps,
Maarten

--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany


http://www.maartenbuis.nl
--------------------------

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


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index