Hi, in the following code replicated, I want to find the first year that firm received the treatment so that I may create the post treatment variable (dummy) for each firm.
The following codes generate errors because first() and fillmissing functions may be not be default command. Is there any way to make the following code work or alternative way of doing this job? Thank you.
The following codes generate errors because first() and fillmissing functions may be not be default command. Is there any way to make the following code work or alternative way of doing this job? Thank you.
Code:
sort firmid year gen temp=year if amount_999 > 0 bysort firmid: egen first_year_999=first(temp) bysort firmid: fillmissing first_year_999, with(any) label var first_year_999 "first year receiving 999 funding" gen dummy_999_post=1 if year>=first_year_999 replace dummy_999_post=0 if dummy_999_post==. label var dummy_999_post "Dummy variable =1 from the first year receiving 999 funding and thereafter" drop temp
Comment