Announcement

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

  • How to combine variables?

    Dear all, my question most probable very simple, but I got challenged by it very much:-)
    In my dataset (medication list recorded in persons in intervention and control group), I already preprocessed dataset som I have given 1 if person receive a medication (f.ex. opioid , antiepileptic etc etc ) and 0 if person dot receiving this medication. the example of data see kindly below:
    id nmedicine3 n_opi3 n_ssri3 n_antiepileptic3 n_furosemide3
    9 12 0 0 0 1 0
    11 8 0 1 0 0 0
    12 3 0 0 0 0 0
    17 7 0 1 0 0 0
    20 8 0 0 0 1 0
    39 6 1 1 0 0 0
    53 8 0 0 0 0 0
    54 3 0 0 0 0 0
    55 7 0 1 0 1 0
    56 6 0 0 0 1 0
    57 6 0 0 0 0 0
    59 6 0 0 0 0 0
    65 9 0 1 0 0 0
    68 14 1 0 0 1 1
    69 6 0 0 0 0 0
    74 9 1 1 0 0 0
    79 7 1 0 0 0 0
    82 5 0 0 0 0 0
    93 7 0 0 0 0 0
    97 10 1 1 0 0 0

    Could you help me with the command to see if the patient receiving the combination of to or more drugs? Like f.ex. id 68 getting both opioids, antiepileptics and furosemide, id 97 getting opioides and ssri... so any of combinations for 2 or more drugs.

    Thanks alot in advance for your help! Natallia

  • #2
    Natallia:
    if you're interested in the total number of medications administered to each patient, you can try:
    Code:
     egen flag=rowtotal(n_*)
    However, please note that the code above will not differentiate for the therapeutical categories prescribed.
    Kind regards,
    Carlo
    (Stata 18.0 SE)

    Comment


    • #3
      If you want to get the result, you may just - tabulate - for that. Or use - count if - , but you may create variables with the egen command with group option.

      Please take a look at the FAQ, particularly on how to share data. You may use the CODE delimiters for that, or the - dataex - command (Stata 15.1) or SSC.
      Last edited by Marcos Almeida; 13 Dec 2017, 03:43.
      Best regards,

      Marcos

      Comment


      • #4
        Dear all,
        thanks alot- It helped much at the moment:-)

        Thanks again,
        Natallia

        Comment

        Working...
        X