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

st: Re: tab


From   Roger Newson <roger.newson@kcl.ac.uk>
To   statalist@hsphsun2.harvard.edu
Subject   st: Re: tab
Date   Mon, 22 Dec 2003 15:36:47 +0000

At 15:07 22/12/03 +0100, Ulrich Kohler wrote (in reply to Andreas Aschbacher):
Andreas Aschbacher wrote:
> Dear collegues !
> I want to add the column  > 100 - Cum <
> to the following table which I get with tab z1
>
> . tab z1
>
>                            z1 |      Freq.     Percent        Cum.
> 100 - Cum
> ------------------------------+-----------------------------------
>   1. < 20 mSv                 |      2,086        0.52        0.52
>   99.48
>       2.  >= 20 mSv           |     32,767        8.21        8.73
>  ..
>       3.  >= 40 mSv           |    105,238       26.35       35.08
> ..
>       4.  >= 60 mSv           |    122,592       30.70       65.78
> ..
>       5.  >= 80 mSv           |     77,056       19.30       85.08
> ..
>      6.  >= 100 mSv           |     31,572        7.91       92.99
> 7.01
>      ........                                ........           .....
> .......           ......
>
> How to get the table with 100 - Cum inclusive ?
> Thank you very much
> andreas

I propose to form a dataset containig the results and and to display this
dataset either with -list- or -tabdisp-. You may also transfer the dataset
with the results to a Desktop Publishing Program with -outsheet-.

The following may deal as a starting point:

--------------------------------------
contract z1, freq(n)
gen N = sum(n)
gen f = n/N[_N] * 100
gen F = sum(f)
gen F100 = 100 - F
tabdisp z1, cellvar(n f F F100)
-------------------------------------

Be aware that -contract- changes your dataset. You should therefore save you
data before using the above.

Andreas might also like to check out my -xcontract- package, downloadable from SSC. -xcontract- is an extended version of -contract-, which produces an output data set containing frequencies, percentages and (optionally) cumulative frequencies and percentages. The user may list this output data set, save to a disk file, or write it to memory, overwriting any pre-existing data.

I hope this helps.

Roger


--
Roger Newson
Lecturer in Medical Statistics
Department of Public Health Sciences
King's College London
5th Floor, Capital House
42 Weston Street
London SE1 3QD
United Kingdom

Tel: 020 7848 6648 International +44 20 7848 6648
Fax: 020 7848 6620 International +44 20 7848 6620
or 020 7848 6605 International +44 20 7848 6605
Email: roger.newson@kcl.ac.uk
Website: http://www.kcl-phs.org.uk/rogernewson

Opinions expressed are those of the author, not the institution.

*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/




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