Announcement

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

  • have 2 variables right and left, but only want to use the operated side

    I have variables that represent the total flexion (movement) for right knee and left knee as seen here whilst squatting (see below)

    I only want to keep the observation for which the patient was operated on

    For eg if laterality =R for patient =2 I only want to keep the observations for the right knee so I can do my regressions/statistics for eg


    reg med_rtkneerange_squats procedure



    Perhaps I may be going down the wrong route, by asking to just 'keep' perhaps I can use another way... open to suggestions


    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input long ID byte procedure float OpDate long laterality float(med_rtkneerange_squats med_ltkneerange_squats med_rtkneemax_squats med_ltkneemax_squats)
      2 1 17349 2  40.77314   24.0198   46.12973 67.17729
      9 0 17618 1 32.675465  55.41523   81.28281 67.09322
     10 1 17603 2 11.908855  20.10073   54.06376 66.11465
     13 0 17626 1  43.14063  34.58105  68.852776 65.76185
     16 0 17815 1  19.51295  29.75897    38.1848 49.84944
     29 1 17826 1         .         .          .        .
     44 0 18014 2   53.8275  7.957477   51.61894 51.96389
     54 1 18168 1  21.67182 21.440784  64.480415 45.96501
     57 1 18150 1   29.9592   41.1226   57.49112 49.03075
     64 0 18301 1 25.949486  19.30579 -72.664085 60.57241
    255 1 18413 1 17.355415  48.27696  72.666565 60.82507
    262 1 18360 2  62.60757   8.53551  72.188095 94.94001
    end
    format %td OpDate
    label values procedure p3
    label def p3 0 "TKR", modify
    label def p3 1 "PFR", modify
    label values laterality laterality
    label def laterality 1 "L", modify
    label def laterality 2 "R", modify

  • #2
    First create new variables that pick their values from the corresponding rt or lt variable, according to the value of laterality. Then drop the rt and lt variables.
    Code:
    foreach x in kneerange_squats kneemax_squats {
        gen med_`x' = cond(laterality == "L":laterality, med_lt`x', med_rt`x')
    }
    drop med_rt* med_lt*

    Comment

    Working...
    X