Announcement

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

  • How to calculate ratio with two conditions

    I want to calculate completion rate for two conditions.

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input float(grid treatment_status enrolled) byte dropout
    301 1 1 .
    209 1 1 1
    209 1 1 1
    209 1 1 1
    206 1 1 1
    301 1 1 1
    301 2 1 .
    204 2 1 .
    207 2 1 1
    209 2 1 .
    end
    label values treatment_status treatment_lbl
    label def treatment_lbl 1 "[T1] Information Only", modify
    label def treatment_lbl 2 "[T2] Out of Village Mobilization (OVM)", modify
    I want to be able to compute the completion rate (dropout != 0 ) for each grid in each treatment arm.

    Thank you!

  • #2
    Aqib:
    do you mean something along the following lines?:
    Code:
    . bysort grid treatment_status: egen wanted=sum( enrolled ) if dropout!=.
    
    . list
    
         +-----------------------------------------------------------------------------+
         | grid                         treatment_status   enrolled   dropout   wanted |
         |-----------------------------------------------------------------------------|
      1. |  204   [T2] Out of Village Mobilization (OVM)          1         .        . |
      2. |  206                    [T1] Information Only          1         1        1 |
      3. |  207   [T2] Out of Village Mobilization (OVM)          1         1        1 |
      4. |  209                    [T1] Information Only          1         1        3 |
      5. |  209                    [T1] Information Only          1         1        3 |
         |-----------------------------------------------------------------------------|
      6. |  209                    [T1] Information Only          1         1        3 |
      7. |  209   [T2] Out of Village Mobilization (OVM)          1         .        . |
      8. |  301                    [T1] Information Only          1         .        . |
      9. |  301                    [T1] Information Only          1         1        1 |
     10. |  301   [T2] Out of Village Mobilization (OVM)          1         .        . |
         +-----------------------------------------------------------------------------+
    
    .
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      No. For each grid, I want the completion rate in each treatment arm. So if [T2] is able to stay enrolled and not dropout. I want the rates for all [T2] that were succesfully able to stay enrolled. I hope I am clear now.

      Comment


      • #4
        Aqib:
        sorry, but I do not follow you.
        In your example, there's no such a thing as -dropout=0-.
        In addition, could you please create a column with the values you 'd want to see? Thanks,
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment


        • #5
          Yes, sorry. That is a mistake. Please ignore the dropout !=0.

          I want to see completion rate of each grid in each treatment arm. Specifically, if a grid and treatment arm is able to have dropout ==. (missing) then should have a completion rate of 1 or 100%, and so on. I hope this makes things clear now.

          Comment


          • #6
            Aqib:
            Code:
            .  bysort grid treatment_status: egen wanted=sum( enrolled ) if dropout==.
            
            
            . list
            
                 +-----------------------------------------------------------------------------+
                 | grid                         treatment_status   enrolled   dropout   wanted |
                 |-----------------------------------------------------------------------------|
              1. |  204   [T2] Out of Village Mobilization (OVM)          1         .        1 |
              2. |  206                    [T1] Information Only          1         1        . |
              3. |  207   [T2] Out of Village Mobilization (OVM)          1         1        . |
              4. |  209                    [T1] Information Only          1         1        . |
              5. |  209                    [T1] Information Only          1         1        . |
                 |-----------------------------------------------------------------------------|
              6. |  209                    [T1] Information Only          1         1        . |
              7. |  209   [T2] Out of Village Mobilization (OVM)          1         .        1 |
              8. |  301                    [T1] Information Only          1         .        1 |
              9. |  301                    [T1] Information Only          1         1        . |
             10. |  301   [T2] Out of Village Mobilization (OVM)          1         .        1 |
                 +-----------------------------------------------------------------------------+
            
            .
            Kind regards,
            Carlo
            (Stata 19.0)

            Comment

            Working...
            X