Dear Statalisters,

I have job level data and I am trying to estimate the impact of US state labor regulations on employment flows. For each state, I have an indicator
Code:
total
measuring the level of labor regulations. Over the years, regulations change and it results in changes in this indicator.

I consider each change in
Code:
total
in the regulation to be a treatment. However, some states have more treatments than others, and these treatments occur in different years depending on states.

For example:

- Ohio is treated in 2001, 2005, 2007
- New York is treated in 2003, 2008

What I'd like to do is create a treatment variable that puts in my treatment group states that are treated in t and in the control group states that have been treated in previous time periods or untreated states. How could I do that?

Also, how can I create a time variable that suits such a design? Unlike "regular" diff-in-diff I'd have more than one before and after period.

This is a sample of my data, for more clarity:

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input float(id state) int(geography industry year) float total
506818 5 5043 2372 2007 17.75
546442 5 5061 8141 2007 17.75
587679 5 5089 4533 2007 17.75
679116 5 5141 7212 2007 17.75
664185 5 5133 5629 2007 17.75
598514 5 5095 2372 2007 17.75
503980 5 5041 2213 2007 17.75
555508 5 5067 5414 2007 17.75
643112 5 5123 4483 2007 17.75
668622 5 5137 2373 2007 17.75
460615 5 5017 2379 2007 17.75
620249 5 5113 4413 2007 17.75
566365 5 5071 8123 2007 17.75
552662 5 5065 5412 2007 17.75
664246 5 5133 6213 2007 17.75
431871 5 5003 2383 2007 17.75
539444 5 5057 7225 2007 17.75
584820 5 5087 4249 2007 17.75
576599 5 5083 1129 2007 17.75
438348 5 5005 5323 2007 17.75
491213 5 5033 4543 2007 17.75
556943 5 5069 2372 2007 17.75
629376 5 5117 2213 2007 17.75
562965 5 5071 2361 2007 17.75
549502 5 5063 5416 2007 17.75
601389 5 5097 5416 2007 17.75
503647 5 5039 8122 2007 17.75
666960 5 5135 5222 2007 17.75
585658 5 5087 5614 2007 17.75
615223 5 5109 4842 2007 17.75
466895 5 5019 8123 2007 17.75
453921 5 5011 5415 2007 17.75
693543 5 5147 5242 2007 17.75
581808 5 5085 4842 2007 17.75
692953 5 5147 4413 2007 17.75
695385 5 5149 5242 2007 17.75
482653 5 5031 3121 2007 17.75
572346 5 5077 7139 2007 17.75
600918 5 5097 4413 2007 17.75
540617 5 5059 4239 2007 17.75
567352 5 5073 4885 2007 17.75
689255 5 5145 4884 2007 17.75
445451 5 5007 6115 2007 17.75
643982 5 5123 5312 2007 17.75
609849 5 5105 6232 2007 17.75
460115 5 5015 8121 2007 17.75
623101 5 5115 1123 2007 17.75
502762 5 5039 5312 2007 17.75
473004 5 5023 7211 2007 17.75
451732 5 5009 7121 2007 17.75
575405 5 5081 4531 2007 17.75
678458 5 5141 5621 2007 17.75
465506 5 5019 5611 2007 17.75
582693 5 5085 5614 2007 17.75
494821 5 5035 4412 2007 17.75
535143 5 5055 7111 2007 17.75
660653 5 5131 6231 2007 17.75
609848 5 5105 6232 2007 17.75
645313 5 5123 7225 2007 17.75
556694 5 5069 1121 2007 17.75
593076 5 5091 8112 2007 17.75
576596 5 5083 1129 2007 17.75
615110 5 5109 4533 2007 17.75
468181 5 5021 4421 2007 17.75
437702 5 5005 4855 2007 17.75
555025 5 5067 4542 2007 17.75
542646 5 5059 6242 2007 17.75
621881 5 5113 6116 2007 17.75
581282 5 5085 4483 2007 17.75
693959 5 5147 8111 2007 17.75
518208 5 5047 6212 2007 17.75
490633 5 5033 4451 2007 17.75
545182 5 5061 5242 2007 17.75
464489 5 5019 4511 2007 17.75
605467 5 5103 3118 2007 17.75
491373 5 5033 4911 2007 17.75
608411 5 5103 7113 2007 17.75
531883 5 5055 4248 2007 17.75
447748 5 5009 3111 2007 17.75
605119 5 5101 8131 2007 17.75
576394 5 5081 8122 2007 17.75
460613 5 5017 2379 2007 17.75
643479 5 5123 4542 2007 17.75
609754 5 5105 6213 2007 17.75
554048 5 5067 3323 2007 17.75
506204 5 5041 7224 2007 17.75
606608 5 5103 4483 2007 17.75
604520 5 5101 5413 2007 17.75
613938 5 5107 8139 2007 17.75
541974 5 5059 5411 2007 17.75
462048 5 5017 5617 2007 17.75
463237 5 5019 2362 2007 17.75
576581 5 5083 1123 2007 17.75
474809 5 5027 2123 2007 17.75
602151 5 5099 2213 2007 17.75
456566 5 5015 3273 2007 17.75
594028 5 5093 3112 2007 17.75
665144 5 5135 1114 2007 17.75
533147 5 5055 4542 2007 17.75
677238 5 5141 4244 2007 17.75
end
I know there are multiple posts on this topic but I can't seem to find an answer to my problem or fail to understand/apply the answers properly. Any help is appreciated

Thanks!