Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Type mismatch with kap command

    Using Stata 17, I have two variables (var1 and var2) with 30 entries each, and each entry categorised to A, E or N. I can run 'tabulate' fine, but if I try:

    --> kap var1 var2

    I get:

    --> type mismatch r(109)

    The variable types are str1, which looking at the manual for 'kap' seems like it should be okay? Not sure why it isn't playing ball.
    Last edited by Seb Janner; 30 Oct 2023, 08:57.

  • #2
    The -kap- command does not accept string variables. -tabulate- is one of the relatively few Stata categorical variable commands that does. The -help- documentation for -kap- doesn't seem to explicitly mention this fact, as near as I can tell. Create numeric versions of var1 and var2 and -kap- should work for you.
    Code:
    encode var1, gen(num_var1)
    encode var2, gen(num_var2)
    kap num_var1 num_var2

    Comment

    Working...
    X