Hi all,

I have run into a bit of an issue. I am attempting to make a parallel trend twoway line plot, but am having difficulty creating a treatment and control variable and plotting it. The variable that I need the mean of to plot is my expmr variable and it is unique by HHID. There are three-panel bins 2008-2009, 2010-2011, & 2012-2013, with each unique HHID being represented once in each of these bins. The intervention is based on the distance to line and happens in 2010 and again in 2012 and marked by treatment1. It is a staggered entry intervention, so the post is after 2010 and post2 is after 2012. My issue is that I'm not sure how to create the treatment and control group because the distance for everyone in 2008-2009 is the furthest value due to the infrastructure intervention not being put in place. So, e.g. if an hhid gets the treatment in say 2011 it will show up in both hhid observations, but not the first in 2008/09. I am wanting to create a variable that is a 1 for the same HHID in all three panels if the treatment was received so that I can compare it to the control group. Ideally, I'd have two treatment groups separated by if they received the intervention in post vs post2.

Last, I'm struggling to make a lineplot that represents either the mean of expmr in relation to the treatment and control groups over time (either intyear or panels). It's a difference-in-differences study and I need to establish the parallel trend prior to intervention. Here's all my code if there's anything else I can provide please let me know!

Code:
* Example generated by -dataex-. For more info, type help dataex
clear
input double(expmr hhid) int intyear double(distance treatment1 post post2 panels)
 1966742.125 1010140020171 2012   .71 0 1 1 3
  2453002.75 1010140020171 2010 4.124 0 1 0 2
 1730037.125 1010140020171 2008 4.124 0 0 0 1
 1364008.375 1010140020284 2010 4.124 0 1 0 2
453940.71875 1010140020284 2008 4.124 0 0 0 1
 563614.4375 1010140020284 2012   .71 0 1 1 3
   7136121.5 1010140020297 2008 4.124 0 0 0 1
     6136596 1010140020297 2010 4.124 0 1 0 2
     5479784 1010140020297 2012   .71 0 1 1 3
     3419913 1010140020297 2011   .71 0 1 0 2
end