Announcement

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

  • summary statistics with filtering (type mismatch r(109)

    Hi everyone,

    I am trying to obtain summary of "tot_benes" (a numeric variable) categorized by "year" filtered to "hcpcs_cd" (string data). My "year" was initially recognized as a number so I converted it to string. I am still receiving an error: type mismatch r(109).

    Any advice?

    Thanks for the help.

    . by year, sort : summarize tot_benes if hcpcs_cd = 93015

    -------------------------------------------------------------------------------------------------------------------------------------
    -> year = 13
    type mismatch
    r(109);

    . tostring year, generate(year1)
    year1 generated as str2
    . by year1, sort : summarize tot_benes if hcpcs_cd = 93015

    -------------------------------------------------------------------------------------------------------------------------------------
    -> year1 = 13
    type mismatch
    r(109);

  • #2
    I am not that good with STATA, but you mentioned that hcpcs_cd is a string variable, so you should put the number you want to filter on between " ", shouldn't you ?


    As an addition:

    I runnen the following command with my own dataset, then it worked perfectly. Note however that year is a numerical variable in my dataset.

    by year,sort: sum road_tkm if country=="Poland"
    Last edited by Harina Peternella; 31 Aug 2022, 08:05.

    Comment


    • #3
      That worked, thanks!

      Comment

      Working...
      X