Dear Statalist Users,
I am working with DHS data to explore the effect of refugee exposure in their country on their health outcomes. CASEID defines children born between 2003 and 2015. Plate is their city of residence at the time of survey. Refpop variable is my treatment variable. I would like to create forward values of my treatment variable to test the common trend assumption/pre-existing trends. So, for example, if the value of refpop variable for children born in 2003 is 0, I want my refpop(t+1) variable to be 0 for children born in 2004. Or alternatively, if the value of refpop variable for children born in 2003 is 0, I want my refpop(t+2) variable to be 0 for children born in 2005. Even though it is not shown the data I extracted here, refpop variable for children born in 2012 is missing. And it takes 0 for children born between 2003 and 2011 because there were no any refugees in these years in the country of interest. The actual values of refpop variable starts in 2013. So it takes actual values for children born in and after 2013. Therefore, I would like to create forward values of my treatment variable (refpop) in t+8. However, I could not do it using the following code gen refpop_forward1= refpop[_n+1] (this is an example for t+1) as it does not do the thing I want.
If anyone can help me I will be really happy.
Thank you so much.
I am working with DHS data to explore the effect of refugee exposure in their country on their health outcomes. CASEID defines children born between 2003 and 2015. Plate is their city of residence at the time of survey. Refpop variable is my treatment variable. I would like to create forward values of my treatment variable to test the common trend assumption/pre-existing trends. So, for example, if the value of refpop variable for children born in 2003 is 0, I want my refpop(t+1) variable to be 0 for children born in 2004. Or alternatively, if the value of refpop variable for children born in 2003 is 0, I want my refpop(t+2) variable to be 0 for children born in 2005. Even though it is not shown the data I extracted here, refpop variable for children born in 2012 is missing. And it takes 0 for children born between 2003 and 2011 because there were no any refugees in these years in the country of interest. The actual values of refpop variable starts in 2013. So it takes actual values for children born in and after 2013. Therefore, I would like to create forward values of my treatment variable (refpop) in t+8. However, I could not do it using the following code gen refpop_forward1= refpop[_n+1] (this is an example for t+1) as it does not do the thing I want.
If anyone can help me I will be really happy.
Thank you so much.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str15 CASEID float(plate child_birth_year) double refpop " 60521 2" 35 2003 0 " 3416 5 2" 27 2003 0 " 341211 2" 27 2003 0 " 1811 8 2" 42 2003 0 " 331713 4" 65 2003 0 " 203414 2" 46 2003 0 " 300213 4" 4 2003 0 " 2123 7 2" 31 2003 0 " 2701 5 2" 5 2003 0 " 3619 2 2" 56 2003 0 " 50210 2" 35 2003 0 " 13018 2" 34 2003 0 " 221022 2" 38 2003 0 " 130313 2" 26 2003 0 " 13719 2" 34 2003 0 " 137 6 2" 34 2003 0 " 290813 9" 52 2003 0 " 1601 3 2" 42 2003 0 " 1903 2 2" 1 2003 0 " 1014 2 4" 16 2003 0 " 250214 2" 37 2003 0 " 310910 2" 25 2003 0 " 2008 9 2" 7 2003 0 " 201614 2" 31 2003 0 " 102 3 2" 34 2003 0 " 60819 2" 45 2003 0 " 3213 2 2" 44 2003 0 " 2006 9 2" 7 2003 0 " 220523 2" 38 2003 0 " 222417 2" 68 2003 0 " 100619 2" 16 2003 0 " 202825 2" 33 2003 0 " 2603 7 2" 19 2003 0 " 13812 2" 34 2003 0 " 14621 2" 34 2003 0 " 151110 2" 6 2003 0 " 190414 2" 1 2003 0 " 360215 5" 2 2004 0 " 2024 2 2" 33 2004 0 " 300321 2" 4 2004 0 " 2139 3 2" 80 2004 0 " 3017 3 2" 25 2004 0 " 150213 2" 6 2004 0 " 350921 2" 27 2004 0 " 51414 2" 35 2004 0 " 200513 2" 7 2004 0 " 2131 7 2" 33 2004 0 " 130113 2" 11 2004 0 " 3016 8 2" 25 2004 0 " 2604 4 2" 19 2004 0 " 323 8 2" 59 2004 0 " 50716 2" 35 2004 0 " 3410 1 1" 27 2004 0 " 341610 4" 27 2004 0 " 161022 4" 42 2004 0 " 221613 2" 58 2004 0 " 60122 2" 9 2004 0 " 321118 2" 44 2004 0 " 201522 2" 31 2004 0 " 300210 5" 4 2004 0 " 111110 2" 54 2004 0 " 3413 3 2" 27 2004 0 " 10321 2" 34 2004 0 " 341319 1" 27 2004 0 " 300320 1" 4 2004 0 " 241110 2" 55 2004 0 " 3101 2 3" 4 2004 0 " 101522 2" 16 2004 0 " 3507 1 1" 21 2004 0 " 3207 7 2" 23 2004 0 " 3116 1 2" 36 2004 0 " 230515 4" 50 2004 0 " 212615 2" 32 2004 0 " 341010 2" 27 2004 0 " 2210 3 2" 38 2004 0 " 311614 4" 36 2004 0 " 282723 2" 61 2004 0 " 281816 2" 53 2004 0 " 115 3 2" 34 2004 0 " 140314 2" 26 2004 0 " 191118 4" 1 2004 0 " 12710 2" 34 2004 0 " 240314 2" 55 2004 0 " 3108 2 2" 25 2004 0 " 100617 2" 16 2004 0 " 2409 4 2" 55 2004 0 " 1302 2 2" 14 2004 0 " 3202 2 2" 13 2004 0 " 3103 5 4" 4 2004 0 " 320818 2" 23 2004 0 " 2513 6 2" 67 2004 0 " 3403 5 2" 27 2004 0 " 1911 6 2" 1 2004 0 " 311110 1" 25 2004 0 " 2416 5 2" 55 2004 0 " 260317 2" 19 2004 0 " 160615 4" 42 2004 0 " 351914 2" 72 2004 0 " 51112 2" 35 2004 0 " 200424 2" 7 2004 0 end

Comment