There's no dilemma here. The solution is not to -destring-
but just using correct syntax. As -dxcode1- is string,
you must bind string values within " ".
tab dxcode1 if dxcode1 == "4010-"
By the way, such a command would do nothing
useful except count values.
count if dxcode1 == "4010-"
is more direct for that purpose.
Nick
[email protected]
Suzy
>
> I need the frequency of some of the categories under the string
> variables. For example, for a numeric variable such as sex, I get the
> frequency easily....
> . tab sex
>
> sex | Freq. Percent Cum.
> ------------+-----------------------------------
> 1 | 133,769 40.88 40.88
> 2 | 193,485 59.12 100.00
> ------------+-----------------------------------
> Total | 327,254 100.00
>
> For the string variables such as dxcode1, I cannot obtain the
> frequency
> for either code:
>
> tab dxcode1 if dxcode1==4010-
> invalid syntax
> r(198);
>
> . tab dxcode1 if dxcode1==40200
> type mismatch
> r(109);
>
> Thus, I felt that I needed to destring the variable dxcode1. But
> because some observations are coded with dashes, it seems
> that the only
> way to get it to work is to use the ignore and force option, but then
> I'd lose the dashed observations since STATA would treat them as
> missing. So that has been my dilemma.
*
* 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/