Announcement

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

  • Recode categorical variable with 83 categories

    Hello,
    Thanks for any help in advance.Very much a beginner, so apologies if this is very basic. I am trying to recode a categorical variable with a large number of categories witch are processes that patients in A&E undergo, and define the labels at the same time. I have tried to use the STATA manual which suggests the following approach:
    . recode item* (1 2 = 1 positive) (3 = 2 neutral) (4 5 = 3 negative), pre(R) > label(Item3) and so I have written the following:

    Code:
    recode Proc1_n* (5 49 55 = 1. admin of oral meds) (1 3 32 = 2. Admin IV meds excl IV Abx) (2 = 3. Admin meds via NG) (4 = 4. Admin IVF) (6 46 69 = 5. Admin anaesthesia regional or local) (7 24 25 80 = 6. Wound dressing or cleaning) (8 9 10 12 63 75 = 7. Cast, sling, traction, other support) (11 45 65 = 8. Assess mobility or loan crutches) (13 = 9. Burns review) (14 = 10. Cardiac monitoring) (15 = 11. Central Line) (16 40 41 = 12. Cannula) (17 36 = 13. Change or insert N Gastro tube) (18 47 48 68 = 14. closed reduction fracture or disloc) (19 20 21 28 76 81 82 83 = 15. Wound closure or suture removal) (22 = 16. Cold Therapy) (23 = 17. Control nosebleed) (26 = 18. Fracture review)(27 = 19. GA)(29 30 52 57 60 = 20. Advice / guidance)(31 = 21. I&D)(33 54 56 = 22. Admin inhaled drug excl O2)(34 79 = 23. Urinary catheter)(35 42 53 = 24. Intubation & Endotrach tube)(37 = 25. Pleural tube)(38 = 26. Interosseous cannulation)(39 = 27. IV Abx)(43 44 = 28. Eye Irrigation)(50 = 29. Topical Skin Cream)(51 61 = 30. Minor surgery)(58 67 = 31. ECG/obs/HI obs)(59 = 32. Oxygen)(62 = 33. Physio)(66 74 = 34. Psychosocial or social assessment)(70 71 = 35. Remove foreign body)(73 77 = 36. Suture or clip removal)(74 64 72 = 37. Remove cast or splint) (78 = 38. Vaccination), pre(R)
    label(Processes1)
    However I get the error:
    Code:
    expected, "admin" found
    r(198);
    also:
    Code:
     label(Processes1)
    invalid syntax
    r(198);
    Would you mind please helping me to understand where I am going wrong? Thank you very much.

    I am using 14.1

  • #2
    You should use double quotes to enclose variable values labels, i.e. strings that follow your recode rules. And you must delete the dot that after your recode rules:
    Code:
    recode Proc1_n* (5 49 55 = 1. admin of oral meds)  //the part in red is wrong
    recode Proc1_n* (5 49 55 = 1 "admin of oral meds") (1 3 32 = 2 "Admin IV meds excl IV Abx") (2 = 3 "Admin meds via NG") (4 = 4 "Admin IVF") (6 46 69 = 5 "Admin anaesthesia regional or local") (7 24 25 80 = 6 "Wound dressing or cleaning") (8 9 10 12 63 75 = 7 "Cast, sling, traction, other support") (11 45 65 = 8 "Assess mobility or loan crutches") (13 = 9 "Burns review") (14 = 10 "Cardiac monitoring") (15 = 11 "Central Line") (16 40 41 = 12 "Cannula") (17 36 = 13 "Change or insert N Gastro tube") (18 47 48 68 = 14 "closed reduction fracture or disloc") (19 20 21 28 76 81 82 83 = 15 "Wound closure or suture removal") (22 = 16 "Cold Therapy") (23 = 17 "Control nosebleed") (26 = 18 "Fracture review")(27 = 19 "GA")(29 30 52 57 60 = 20 "Advice / guidance")(31 = 21 "I&D")(33 54 56 = 22 "Admin inhaled drug excl O2")(34 79 = 23 "Urinary catheter")(35 42 53 = 24 "Intubation & Endotrach tube")(37 = 25 "Pleural tube")(38 = 26 "Interosseous cannulation")(39 = 27 "IV Abx")(43 44 = 28 "Eye Irrigation")(50 = 29 "Topical Skin Cream")(51 61 = 30 "Minor surgery")(58 67 = 31 "ECG/obs/HI obs")(59 = 32 "Oxygen")(62 = 33 "Physio")(66 74 = 34 "Psychosocial or social assessment")(70 71 = 35 "Remove foreign body")(73 77 = 36 "Suture or clip removal")(74 64 72 = 37 "Remove cast or splint") (78 = 38 "Vaccination"), pre(R) label(Processes1)

    Comment


    • #3
      Thank you so much - all sorted - appreciate it a lot!

      Comment

      Working...
      X