Hello,
I am having an issue with my data. I have created a simple example data set here:
Here, I have a panel data set on five families from years 2000 to 2002. Now, I have the year when they have their first kid. Now, I want to run an event study analysis, where I have to create leads and lags period for the families after and from having the first kid. Therefore, I need to create time to treat variables. I got that variable listed as "wanted" here using the following code:
I am having another problem here! Please have a look at the data set above; notice that family_id 4 had kid again at year 2003. Can the previous code still generate the year when they have their first kid? which would still be 2000. In this case I tried the code mentioned above, it worked! However, I still need to determine the families like 4 here, which had kids more than once.
Thank you so much!
I am having an issue with my data. I have created a simple example data set here:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float(Family_id Year had_new_kid Wanted) 1 2000 . 2001 2 2000 . . 3 2000 . . 4 2000 2000 2000 5 2000 . 2002 1 2001 2001 2001 2 2001 . . 3 2001 . . 4 2001 . 2000 5 2001 . 2002 1 2002 . 2001 2 2002 . . 3 2002 . . 4 2002 . 2000 5 2002 2002 2002 1 2003 . 2001 2 2003 . . 3 2003 . . 4 2003 2003 2000 5 2003 . 2002 end
Here, I have a panel data set on five families from years 2000 to 2002. Now, I have the year when they have their first kid. Now, I want to run an event study analysis, where I have to create leads and lags period for the families after and from having the first kid. Therefore, I need to create time to treat variables. I got that variable listed as "wanted" here using the following code:
Code:
bys Family_id (had_new_kid): gen wanted= had_new_kid[1]
Thank you so much!
Comment