|
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: st: count cases of a string variable,
2008/5/1 Tunga Kantarci <[email protected]>:
> 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
Your age variable has all observations numeric. You can simply do
-destring age42, replace-
to get it into numeric format.
The reason why your first -count- returned zero is probably to do with
blanks. I sometimes get leading and trailing blanks when I import data
via -odbc-. If you do
-replace age42 = trim(age42)-, to remove leading and trailing blanks,
and then do a
-count if age42=="65"-, you should get the desired result.
However, it's best to get the variable to numeric via -destring-.
Eva
*
* 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/