I have person-year level data, and I am utilizing DiD that exploits state-level shocks. Each person is assigned to a unique state based on location. I have 10 treated states. While the primary analysis is quite easy to code, I need help with a desire robustness check. I want to write some sort of loop to run placebo (if that's the right term here) tests with treatment assigned to states that should be control states. In other words, I want the placebo analysis to be repeated with the 40 control states and several iterations of assignment among those 40 (can be 10 for each iteration if that is simpler). I have found several topics that seemed adjacent to this, but I could not make sense of using them in my setting. Please let me know if you need any more information.

Justin