Statalist The Stata Listserver


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

st: RE: table stubs


From   "David Harrison" <[email protected]>
To   <[email protected]>
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.

David


prog bigtab, byable(recall)
    syntax varname(string) [if] [in] [, Missing sort]
    marksample touse, novarlist
    if "`missing'" == "" {
        markout `touse' `varlist', strok
    }
    qui {
        preserve
        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']
    }
end 

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Peter Adamson
Sent: 23 May 2006 11:11
To: [email protected]
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 http://www.messagelabs.com/email 
______________________________________________________________________

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index