0

I have the vector v1, with 26 elements, either being 'Live' or 'Non-live'. When I use tabulate(v1), it returns

tabulate(v1)
       Value    Count   Percent
        cat1        0      0.00%
        cat2        0      0.00%
        Live        5     19.23%
    Non-live       21     80.77%

This affects crosstab also. How to prevent tabulate and crosstab functions taking non-existing variables in the vector in to account?

1 Answers1

0

From the example here it suggests you might get results in tabulate that aren't in your data if your variable isn't categorical. Try converting it to categorical and running tabulate again.

categorical_v1 = categorical(v1);
tabulate(categorical_v1)

It looks like v1 could already be categorical, but perhaps it was not set up correctly, so cat1 and cat2 are remnants of this. "Recategorising" the data should remove these extra categories.

Dominic D
  • 1,778
  • 2
  • 5
  • 12