Announcement

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

  • Adding a new option to a variable and then assigning observations to is

    Hi,
    I have variables finaldx and final dxgroup, and I am trying to assign values with finaldx of Cauda equine syndrome to finaldxgroup of Cauda equina syndrome. So I tried this:
    replace finaldxgroup == "Cauda Equina Syndrome" if finaldx = "Cauda equina syndrome"
    however, I get a r(198) error and it says "== invalid name". I think this is because of finaldxgroup doesn't have a Cauda equine syndrome option:
    . tab finaldxgroup

    FinalDxGroup | Freq. Percent Cum.
    --------------+-----------------------------------
    Complication | 1,243 2.04 2.04
    Congenital | 741 1.22 3.26
    DegenSpine | 10,595 17.39 20.65
    Hydrocephalus | 1,812 2.97 23.62
    Infection | 1,659 2.72 26.34
    Misc | 1,607 2.64 28.98
    None | 4,693 7.70 36.68
    Oncology | 7,648 12.55 49.24
    SCI | 7,262 11.92 61.15
    TBI | 14,189 23.29 84.44
    Vascular | 9,479 15.56 100.00
    --------------+-----------------------------------
    Total | 60,928 100.00

    So I sort of need to add the option of "Cauda equina syndrome" to finaldxgroup, and then assign the observations that have finaldx == "Cauda equine syndrome" to this.


    Can anyone help? Thank you!


  • #2
    Josie:
    welcome to this forum.
    Perhaps the issue is simply that:
    Code:
    replace finaldxgroup == "Cauda Equina Syndrome" if finaldx = "Cauda equina syndrome"
    is an illegal Stata code, whereas:
    Code:
    replace finaldxgroup = "Cauda Equina Syndrome" if finaldx == "Cauda equina syndrome"
    might work as expected.
    Kind regards,
    Carlo
    (StataNow 18.5)

    Comment


    • #3
      Ah I see, thank you Carlo!

      Comment

      Working...
      X