I have a string variable nation2 distributed as follows:
Now I encode it in a numeric variable to be used in a regression model
Now I want to count the instances of nation_encoded=="OTHER".
If I do
I have to do
How can I use the command with the label, not with the numeric value?
Is there something like
?
Code:
. tab nation2, m nation2 | Freq. Percent Cum. ------------+----------------------------------- | 51,292 16.10 16.10 OTHER | 212,447 66.68 82.78 SE | 54,854 17.22 100.00 ------------+----------------------------------- Total | 318,593 100.00
Code:
encode nation2, gen(nation_encoded)
Code:
. tab nation_encoded, nolab m nation_enco | ded | Freq. Percent Cum. ------------+----------------------------------- 1 | 212,447 66.68 66.68 2 | 54,854 17.22 83.90 . | 51,292 16.10 100.00 ------------+----------------------------------- Total | 318,593 100.00
Now I want to count the instances of nation_encoded=="OTHER".
If I do
Code:
. count if nation_encoded=="OTHER" type mismatch
Code:
. count if nation_encoded==1 212,447
Is there something like
Code:
count if nation_encoded==nation_encoded.labels.OTHER
Comment