Announcement

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

  • Create a treatment group

    Hi

    I need to create a Treatment group for businesses(id). The treatment group is those firms received grants( grants>0) for the year>= 2018. How can i create treatment = 1 for the business(id) those received grants 2018 onwards for the year 2015, 2016 & 2017 even though they did not receive any grants from 2015-2017?

  • #2
    Code:
    gen treatment= grant>0 & year>=2018
    bysort business_id: gen wanted= max(treatment)
    See https://www.stata.com/support/faqs/d...ble-recording/ for an elaboration of the technique.

    Comment


    • #3
      Thanks for this. Unfortunately the bysort syntax didnt work. Not sure why. It shows invalid syntax

      Comment


      • #4
        I'm pretty sure Andrew Musau meant to say:
        Code:
        bysort business_id: egen wanted= max(treatment)

        Comment


        • #5
          It worked, thanks. Needed to be egen instead of gen.

          Comment


          • #6
            Originally posted by Clyde Schechter View Post
            I'm pretty sure Andrew Musau meant to say:
            Code:
            bysort business_id: egen wanted= max(treatment)
            Yes, thank you for the correction.

            Comment

            Working...
            X