Announcement

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

  • How to equally assign the variable to control group?

    Given the example below

    Click image for larger version

Name:	3.PNG
Views:	1
Size:	4.0 KB
ID:	1656356


    I want to equally assign the variable "sales", to the control group, specifically matched individuals "1" and "3". (matching result: 4 and 1, 5 and 3)

    How can I?

  • #2
    Perhaps something like this will be a useful approach, starting you toward what you seek.
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input float(id sales treatment matching)
    1  . 0 .
    2  . 0 .
    3  . 0 .
    4 55 1 1
    5 60 1 3
    end
    
    preserve
    drop if treatment==0
    rename id match_id
    rename sales match_sales
    rename matching id
    tempfile match
    save `match'
    restore
    merge m:1 id using `match'
    list, clean abbreviate(16)
    Code:
    . list, clean abbreviate(16)
    
           id   sales   treatment   matching   match_id   match_sales            _merge  
      1.    1       .           0          .          4            55       Matched (3)  
      2.    2       .           0          .          .             .   Master only (1)  
      3.    3       .           0          .          5            60       Matched (3)  
      4.    4      55           1          1          .             .   Master only (1)  
      5.    5      60           1          3          .             .   Master only (1)
    Please note the use of the dataex command to provide example data for the reader to copy and paste for developing and testing code. Take a few moments to review the Statalist FAQ linked to from the top of the page, as well as from the Advice on Posting link on the page you used to create your post. Note especially sections 9-12 on how to best pose your question. It is particularly helpful to copy commands and output from your Stata Results window and paste them into your Statalist post using code delimiters [CODE] and [/CODE], and to use the dataex command to provide sample data, as described in section 12 of the FAQ.

    The more you help others understand your problem, the more likely others are to be able to help you solve your problem.

    Comment

    Working...
    X