|
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: st: count cases of a string variable,
Thanks for the reply. I was trying to do the second one, which you mentioned
my command is legal. But it does not work. Why?:
tab age42
age q4 | Freq. Percent Cum.
----------------------------------------+-----------------------------------
61 | 588 32.04 32.04
63 | 640 34.88 66.92
65 | 607 33.08 100.00
----------------------------------------+-----------------------------------
Total | 1,835 100.00
describe age42
storage display value
variable name type format label variable label
----------------------------------------------------------------------------
----------------------------------------------------------------------------
---
age42 str80 %80s age q4
count if age42 == "65"
0
After I converted the "age42" to "age42num" I get what I want:
tab age42num
age q4 | Freq. Percent Cum.
----------------------------------------+-----------------------------------
61 | 588 32.04 32.04
63 | 640 34.88 66.92
65 | 607 33.08 100.00
----------------------------------------+-----------------------------------
Total | 1,835 100.00
describe age42num
storage display value
variable name type format label variable label
----------------------------------------------------------------------------
----------------------------------------------------------------------------
---
age42num long %80.0g ttage42 age q4
count if age42num == 3
607
*
* 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/