Advertisement
Guest User

Untitled

a guest
May 4th, 2023
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.48 KB | None | 0 0
  1. * Example generated by -dataex-. For more info, type help dataex
  2. * dataex primaryprovince type month year1
  3. clear
  4. input str20 primaryprovince str22 type float(month year1)
  5. "Kabul" "" 4 2009
  6. "Kabul" "ISAF" 4 2011
  7. "Kabul" "ISAF" 4 2013
  8. "Kabul" "INS" 4 2013
  9. "Kabul" "INS" 4 2014
  10. "Kabul" "" 4 2008
  11. "Kabul" "Civilians" 4 2011
  12. "Kabul" "" 4 2012
  13. "Kabul" "Afghan Military" 4 2013
  14. "Kabul" "Civilians" 4 2013
  15. "Kabul" "INS" 4 2013
  16. "Kabul" "" 4 2014
  17. "Kabul" "INS" 4 2014
  18. "Kabul" "Civilians" 4 2014
  19. "Kabul" "" 4 2014
  20. "Kabul" "" 4 2009
  21. "Kabul" "INS" 4 2011
  22. "Kabul" "" 4 2012
  23. "Kabul" "INS" 4 2014
  24. "Kabul" "INS" 4 2014
  25. "Kabul" "" 4 2007
  26. "Kabul" "ISAF" 4 2007
  27. "Kabul" "AUP" 4 2009
  28. "Kabul" "" 4 2009
  29. "Kabul" "INS" 4 2014
  30. "Kabul" "INS" 4 2014
  31. "Kabul" "GIRoA" 4 2014
  32. "Kabul" "" 4 2010
  33. "Kabul" "Afghan Military" 4 2010
  34. "Kabul" "Afghan Military" 4 2013
  35. "Kabul" "" 4 2014
  36. "Kabul" "INS" 4 2014
  37. "Kabul" "INS" 4 2014
  38. "Kabul" "Afghan Military" 4 2014
  39. "Kabul" "Civilians" 4 2007
  40. "Kabul" "ISAF" 4 2008
  41. "Kabul" "ISAF" 4 2013
  42. "Kabul" "Afghan Military" 4 2013
  43. "Kabul" "ISAF" 4 2013
  44. "Kabul" "" 4 2008
  45. "Kabul" "Civilians" 4 2009
  46. "Kabul" "" 4 2009
  47. "Kabul" "Civilians" 4 2006
  48. "Kabul" "ISAF" 4 2007
  49. "Kabul" "" 4 2010
  50. "Kabul" "ISAF" 4 2012
  51. "Kabul" "Civilians" 4 2013
  52. "Kabul" "" 4 2014
  53. "Kabul" "" 4 2009
  54. "Kabul" "ISAF" 4 2011
  55. "Kabul" "Civilians" 4 2011
  56. "Kabul" "AUP" 4 2009
  57. "Kabul" "ISAF" 4 2009
  58. "Kabul" "ISAF" 4 2010
  59. "Kabul" "Afghan Military" 4 2009
  60. "Kabul" "" 4 2009
  61. "Kabul" "ISAF" 4 2010
  62. "Kabul" "" 4 2011
  63. "Kabul" "" 4 2009
  64. "Kabul" "" 4 2009
  65. "Kabul" "Infrastructure" 4 2010
  66. "Kabul" "" 4 2011
  67. "Kabul" "Afghan Military" 4 2014
  68. "Kabul" "ISAF" 4 2014
  69. "Kabul" "" 4 2007
  70. "Kabul" "ISAF" 4 2008
  71. "Kabul" "ISAF" 4 2012
  72. "Kabul" "" 4 2013
  73. "Kabul" "" 4 2008
  74. "Kabul" "ISAF" 4 2008
  75. "Kabul" "Civilians" 4 2011
  76. "Kabul" "INS" 4 2012
  77. "Kabul" "" 4 2013
  78. "Kabul" "ISAF" 4 2013
  79. "Kabul" "ISAF" 4 2011
  80. "Kabul" "" 4 2012
  81. "Kabul" "Civilians" 4 2012
  82. "Kabul" "ISAF" 4 2012
  83. "Kabul" "INS" 4 2012
  84. "Kabul" "INS" 4 2012
  85. "Kabul" "" 4 2013
  86. "Kabul" "ABP" 4 2014
  87. "Kabul" "GIRoA" 4 2014
  88. "Kabul" "GIRoA" 4 2014
  89. "Kabul" "" 4 2012
  90. "Kabul" "" 4 2012
  91. "Kabul" "Civilians" 4 2012
  92. "Kabul" "Civilians" 4 2012
  93. "Kabul" "ISAF" 4 2013
  94. "Kabul" "ANCOP" 4 2014
  95. "Kabul" "" 4 2008
  96. "Kabul" "AUP" 4 2008
  97. "Kabul" "AUP" 4 2011
  98. "Kabul" "INS" 4 2011
  99. "Kabul" "" 4 2012
  100. "Kabul" "" 4 2007
  101. "Kabul" "ISAF" 4 2009
  102. "Kabul" "" 4 2009
  103. "Kabul" "INS" 4 2011
  104. "Kabul" "" 4 2014
  105. end
  106.  
  107. replace primaryprovince = subinstr(primaryprovince, "Federally Administer", "Federally Administered", .)
  108. replace primaryprovince = subinstr(primaryprovince, "Jawzjan", "Jowzjan", .)
  109. replace primaryprovince = subinstr(primaryprovince, "KKhost", "Khost", .)
  110. replace primaryprovince = subinstr(primaryprovince, "SGhazni", "Ghazni", .)
  111. replace primaryprovince = subinstr(primaryprovince, "S Ghazni", "Ghazni", .)
  112. replace primaryprovince = subinstr(primaryprovince, "Sari Pul", "Sar-e Pul", .)
  113. replace primaryprovince = subinstr(primaryprovince, "a Herat", "Hirat", .)
  114. replace primaryprovince = subinstr(primaryprovince, "aPaktika", "Paktika", .)
  115. replace primaryprovince = subinstr(primaryprovince, "dPaktika", "Paktika", .)
  116. replace primaryprovince = subinstr(primaryprovince, "dParwan", "Parwan", .)
  117. replace primaryprovince = subinstr(primaryprovince, "eKhost", "Khost", .)
  118. replace primaryprovince = subinstr(primaryprovince, "gSamangan", "Samangan", .)
  119. replace primaryprovince = subinstr(primaryprovince, "hKapisa", "Kapisa", .)
  120. replace primaryprovince = subinstr(primaryprovince, "hLogar", "Logar", .)
  121. replace primaryprovince = subinstr(primaryprovince, "hWardak", "Wardak", .)
  122. replace primaryprovince = subinstr(primaryprovince, "iHelmand", "Helmand", .)
  123. replace primaryprovince = subinstr(primaryprovince, "lBaghlan", "Baghlan", .)
  124. replace primaryprovince = subinstr(primaryprovince, "lSamangan", "Samangan", .)
  125. replace primaryprovince = subinstr(primaryprovince, "nBalkh", "Balkh", .)
  126. replace primaryprovince = subinstr(primaryprovince, "nHerat", "Herat", .)
  127. replace primaryprovince = subinstr(primaryprovince, "uHerat", "Herat", .)
  128. replace primaryprovince = subinstr(primaryprovince, "Day Kundi", "Daykundi", .)
  129. replace primaryprovince = subinstr(primaryprovince, "Hirat", "Herat", .)
  130. replace primaryprovince = subinstr(primaryprovince, ") Herat", "Herat", .)
  131. replace primaryprovince = subinstr(primaryprovince, "JGhazni", "Ghazni", .)
  132. replace primaryprovince = subinstr(primaryprovince, "Paktya", "Paktiya", .)
  133.  
  134.  
  135. * create year-month date
  136. gen modate = ym(year1, month)
  137. format modate %tm
  138. format %tmMon_CCYY modate
  139. gen type10 = 1
  140. tempfile datax
  141. save `datax'
  142.  
  143. keep if type == "ISAF"
  144. replace type10 = 2
  145. la def type10 1 "Total" 2 "ISAF"
  146. la val type10 type10
  147. append using `datax'
  148. ta type10
  149.  
  150. * aggregate
  151. contract primaryprovince modate type10, zero
  152. rename _freq sigacts
  153. label var sigacts "Significant Activities"
  154. label var type10 "Type"
  155. label var primaryprovince "Province"
  156. label var modate "Time"
  157. label var modate "Period"
  158.  
  159. * remove missing
  160. drop if primaryprovince==""
  161. drop if modate==.
  162.  
  163.  
  164. /* Define a list of provinces */
  165. local provinces ""Badakhshan" "Badghis" "Baghlan" "Balkh" "Bamyan" "Daykundi" "Farah" "Faryab" "Federally Administered Tribal Areas" "Ghazni" "Ghor" "Helmand" "Herat" "Jowzjan" "Kabul" "Kandahar" "Kapisa" "Khost" "Khyber Pakhtunkhwa" "Kunar" "Kunduz" "Laghman" "Logar" "Nangarhar" "Nimroz" "Nuristan" "Paktika" "Paktiya" "Panjshir" "Parwan" "Samangan" "Sar-e Pul" "Takhar" "Uruzgan" "Wardak" "Zabul""
  166.  
  167. /* Loop over each province */
  168. foreach province of local provinces {
  169.  
  170. /* Generate a line plot of sigacts vs modate for the current province and type10 */
  171. twoway (line sigacts modate if type10==1 & primaryprovince == "`province'",lcolor(green)) (line sigacts modate if type10==2 & primaryprovince == "`province'",lcolor(red)), title("Monthly SIGACTs in `province', 2005-2014") xtitle("") ytitle("Totals") legend(label(1 "Total") label(2 "ISAF")) tlabel(2005m1(6)2014m12) xlabel(, angle(vertical))
  172.  
  173. /* Save the plot as an image */
  174. graph export "sigacts_`province'.png", replace
  175. }
  176.  
  177. twoway (line sigacts modate if type10==1 & primaryprovince == "Badakhshan",lcolor(green)) (line sigacts modate if type10==2 & primaryprovince == "Badakhshan",lcolor(red)), title("Monthly SIGACTs in Badakhshan, 2005-2014") xtitle("") ytitle("Totals") legend(label(1 "Total") label(2 "ISAF")) tlabel(2005m1(6)2014m12) xlabel(, angle(vertical)) xline(2005m7(12)2014m12, lcolor(gray*0.20))
  178.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement