Statalist


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

st: RE: RE: -tabulate- and ratio "number of 1/number of 0"


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: RE: -tabulate- and ratio "number of 1/number of 0"
Date   Wed, 6 Feb 2008 12:37:27 -0000

Typo time: for -dem- read -den-. You could also go 

egen num = total(small_profit == 1), by(country) 
egen den = total(small_profit == 0), by(country) 
gen ratio = num / den 
egen tag = tag(country) 
list country ratio if tag 

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Nick Cox
Sent: 06 February 2008 12:24
To: [email protected]
Subject: st: RE: -tabulate- and ratio "number of 1/number of 0"

Some more technique: 

bysort country : gen num = sum(small_profit == 1) 
by country : replace num = num[_N] 
by country : gen den = sum(small_profit == 0) 
by country : replace den = den[_N} 
gen ratio = num / dem 
egen tag = tag(country) 
list country ratio if tag 

Nick 
[email protected] 

Herve STOLOWY
I have a dummy variable "small_profit" and use the -tabulate- command
for several countries (see output excerpt below).

bysort country: tabulate small_profit

------------------------------------------------------------------------
-------------------------------------------
-> country = AUS

small_profi |
          t |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |      2,651       56.52       56.52
          1 |      2,039       43.48      100.00
------------+-----------------------------------
      Total |      4,690      100.00

I am looking for a way to get the ratio: number of "1"/number of "0".

I read the help of -tabulate- and -table- but did not find a solution. 


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

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