Statalist The Stata Listserver

[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: table stubs

From   "David Harrison" <>
To   <>
Subject   st: RE: table stubs
Date   Tue, 23 May 2006 12:21:59 +0100

I don't think there is a way without doing it yourself... Below is how I
would do a one-way table (a two-way one would be a bit harder). I've
recreated the -missing- and -sort- options from -tabulate-, but nothing
else. This code is not extensively tested.


prog bigtab, byable(recall)
    syntax varname(string) [if] [in] [, Missing sort]
    marksample touse, novarlist
    if "`missing'" == "" {
        markout `touse' `varlist', strok
    qui {
        tempvar freq perc cum len
        gen `freq' = 1
        count if `touse'
        gen `perc' = 100/r(N)
        collapse (sum) `freq' (mean) `perc' if `touse', by(`varlist')
        if "`sort'" != "" {
            gsort -`freq' `varlist'
        else {
            sort `varlist'
        gen `cum' = sum(`perc')
        gen `len' = length(`varlist')
        summ `len', meanonly
        local l = r(max)
        set linesize `=`l'+31'
    display as text _n _skip(`l') " {c |}   Freq.   Percent      Cum."
    display as text "{hline `=`l'+1'}{c +}{hline 29}"
    forvalues i=1/`=_N' {
        display as text %`l's `varlist'[`i'] " {c |}" as result ///
            %9.0f `freq'[`i'] %10.2f `perc'[`i'] %10.2f `cum'[`i']

-----Original Message-----
[] On Behalf Of Peter Adamson
Sent: 23 May 2006 11:11
Subject: st: table stubs

Hello,  I need to tabulate a string variable which has a maximum length
of 106 - I note that tab limits the number of characters displayed.  Is
there away around this?

Thanks Peter

This email has been scanned by the MessageLabs Email Security System.
For more information please visit 

*   For searches and help try:

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