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]

st: RE: -statsby- with -tabulate-: confirming output


From   Kieran McCaul <[email protected]>
To   "[email protected]" <[email protected]>
Subject   st: RE: -statsby- with -tabulate-: confirming output
Date   Sun, 26 Jan 2014 04:41:32 +0800

...


-tab- doesn't return row or column percentages.  The macros r(N), r(r), and r(c) simply contain the total N and the number of rows and columns.

If you create the variable "choose" as a byte rather than a string variable, the following will give you most of what you need.



sysuse auto.dta, clear

gen byte choose = price<6000

tab foreign choose, row
statsby total=r(N) nchoose=r(sum) nprop=r(mean), clear by(foreign): summ choose





-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Michael McCulloch
Sent: Sunday, 26 January 2014 2:51 AM
To: [email protected]
Subject: st: -statsby- with -tabulate-: confirming output

Hello,
I'm seeking to create a table with -statsby-, combined with -tabulate-. 
Might anybody have an idea why the row percentages calculated with -tab- by itself, are nor reproduced when -tab- is combined with -statsby-?
Example code:

sysuse auto.dta,clear
gen choose="yes" if price<6000
replace choose="no" if price>=6000
tab foreign choose, row
statsby, clear by(foreign): tab foreign choose, row l

Best wishes,
Michael McCulloch

--
Pine Street Foundation, since 1989
124 Pine Street | San Anselmo | California | 94960-2674
P: (415) 407-1357 | F: (206) 338-2391 | http://www.PineStreetFoundation.org


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


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