Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • generate a share of dependent variable (ratio)

    Hello everyone.

    For example, i have a dependent variable of renew_install_cap of 14 countries from 2000-2016,

    i) how do I create a share of renew_install_cap variable of the total renew_install_cap

    ii) Then, how to create the change in share of the same variable

    At first, I need to create a variable to calculate total sum of renew_install_cap for the period 2000-2016, but I also did not manage to do it correctly.

    Really appreciate for your help, thanks!
    Last edited by farah roslan; 20 Apr 2018, 04:49.

  • #2
    Farah:
    see if -egen- with -total- function fits your needs.
    Kind regards,
    Carlo
    (Stata 18.0 SE)

    Comment


    • #3
      Dear Carlo,

      Actually its for 14 countries, not just for malaysia (I have amended the question in the earlier post). I have egen the tot_ric but what I want is the ratio of the ric for every year. How do I suppose to do the next step?

      Code:
      egen tot_ric= total(ric)
      Code:
      . list country1 year1 ric tot_ric
      
           +------------------------------------------+
           |    country1   year1       ric    tot_ric |
           |------------------------------------------|
        1. |    Thailand    1998    2714.5     2714.5 |
        2. | Phillipines    1998   4602.86   7317.357 |
        3. |       China    1998   59775.7   67093.08 |
        4. |   Singapore    1998   114.046   67207.13 |
        5. |    Malaysia    1998   2432.97   69640.09 |
           |------------------------------------------|
        6. |       Japan    1998   23235.9   92875.95 |
        7. |        Laos    1998   624.331   93500.28 |
        8. | South Korea    1998    1556.7   95056.98 |
        9. |   Indonesia    1998   3995.94   99052.92 |
       10. | New Zealand    1998   5546.41   104599.3 |
           |------------------------------------------|
       11. |     Vietnam    1998   2592.02   107191.4 |
       12. |   Australia    1998   5521.27   112712.6 |
       13. |       India    1998   23180.6   135893.2 |
       14. |   Sri Lanka    1998   1079.96   136973.2 |
       15. | Phillipines    1999   4724.63   141697.8 |
           |------------------------------------------|
       16. | South Korea    1999   1568.25   143266.1 |
       17. | New Zealand    1999   5622.91     148889 |
       18. |   Sri Lanka    1999   1113.85   150002.8 |
       19. |    Malaysia    1999    2439.2     152442 |
       20. |   Australia    1999   6112.71   158554.7 |
           |------------------------------------------|
       21. |       China    1999   66518.3   225073.1 |
       22. |   Singapore    1999   114.767   225187.8 |
       23. |       Japan    1999   24486.6   249674.4 |
       24. |     Vietnam    1999   3014.27   252688.7 |
       25. |   Indonesia    1999   4171.72   256860.4 |
           |------------------------------------------|
       26. |       India    1999   24284.1   281144.4 |
       27. |    Thailand    1999    2747.5   283891.9 |
       28. |        Laos    1999   630.453   284522.4 |
       29. |       China    2000   75845.7   360368.1 |
       30. | New Zealand    2000      5732   366100.1 |
           |------------------------------------------|
       31. |       Japan    2000     23334   389434.1 |
       32. |   Singapore    2000     117.4   389551.5 |
       33. |    Thailand    2000    2985.9   392537.4 |
       34. | Phillipines    2000    4779.3   397316.7 |
       35. |       India    2000   25555.4   422872.1 |
           |------------------------------------------|
       36. | South Korea    2000      1559   424431.1 |
       37. |   Sri Lanka    2000    1160.8   425591.9 |
       38. |        Laos    2000     643.7   426235.6 |
       39. |   Indonesia    2000    5162.3   431397.9 |
       40. |    Malaysia    2000    2448.5   433846.4 |
           |------------------------------------------|
       41. |   Australia    2000    8191.2   442037.6 |
       42. |     Vietnam    2000    3398.9   445436.5 |
       43. |       China    2001   79260.2   524696.7 |
       44. |     Vietnam    2001      3934   528630.7 |
       45. |       Japan    2001     28877   557507.7 |
           |------------------------------------------|
       46. |    Thailand    2001    2998.9   560506.6 |
       47. | New Zealand    2001      5798   566304.6 |
       48. | Phillipines    2001    4856.3   571160.9 |
       49. |   Sri Lanka    2001    1174.4   572335.3 |
       50. |    Malaysia    2001    2433.5   574768.8 |
           |------------------------------------------|
       51. |   Singapore    2001     117.4   574886.2 |
       52. |   Australia    2001    8391.2   583277.4 |
       53. | South Korea    2001      1627   584904.4 |
       54. |       India    2001   26413.5   611317.9 |
       55. |        Laos    2001     644.9   611962.8 |
           |------------------------------------------|
       56. |   Indonesia    2001    4350.6   616313.4 |
       57. |   Sri Lanka    2002    1190.8   617504.2 |
       58. | South Korea    2002      1594   619098.2 |
       59. |   Australia    2002    8492.2   627590.4 |
       60. |       China    2002   83246.7   710837.1 |
           |------------------------------------------|
       61. |     Vietnam    2002    4243.4   715080.5 |
       62. |    Malaysia    2002    2470.5     717551 |
       63. |       Japan    2002     29239     746790 |
       64. |        Laos    2002     645.3   747435.3 |
       65. | Phillipines    2002    5021.7     752457 |
           |------------------------------------------|
       66. |       India    2002   27245.5   779702.5 |
       67. |    Thailand    2002    2448.2   782150.7 |
       68. |   Singapore    2002     117.4   782268.1 |
       69. | New Zealand    2002      5861   788129.1 |
       70. |   Indonesia    2002    4393.2   792522.3 |
           |------------------------------------------|
       71. |    Thailand    2003    2491.5   795013.8 |
       72. |       China    2003   92378.7   887392.5 |
       73. |   Indonesia    2003    4425.9   891818.4 |
       74. |       Japan    2003     30004   921822.4 |
       75. |    Malaysia    2003    2471.5   924293.9 |
           |------------------------------------------|
       76. | New Zealand    2003      5899   930192.9 |
       77. |   Australia    2003    8643.5   938836.4 |
       78. |       India    2003   28956.2   967792.6 |
       79. |   Sri Lanka    2003    1268.3   969060.9 |
       80. |     Vietnam    2003    4295.3   973356.2 |
           |------------------------------------------|
       81. |   Singapore    2003     117.4   973473.6 |
       82. | Phillipines    2003    5457.7   978931.3 |
       83. |        Laos    2003     645.6   979576.9 |
       84. | South Korea    2003    1608.5   981185.4 |
       85. |       Japan    2004     30662    1011847 |
           |------------------------------------------|
       86. | South Korea    2004    1716.6    1013564 |
       87. |        Laos    2004     645.9    1014210 |
       88. | New Zealand    2004      5989    1020199 |
       89. |   Sri Lanka    2004    1307.8    1021507 |
       90. |   Singapore    2004     117.4    1021624 |
           |------------------------------------------|
       91. |     Vietnam    2004    4337.1    1025961 |
       92. |       India    2004   32019.7    1057981 |
       93. |    Malaysia    2004      2475    1060456 |
       94. | Phillipines    2004    5457.7    1065914 |
       95. |       China    2004    103000    1168913 |
           |------------------------------------------|
       96. |   Australia    2004    8902.5    1177816 |
       97. |    Thailand    2004    3114.8    1180930 |
       98. |   Indonesia    2004    4472.7    1185403 |
       99. |   Sri Lanka    2005    1321.8    1186725 |
      100. |       India    2005   34686.5    1221411 |
           |------------------------------------------|
      101. |   Indonesia    2005      5337    1226748 |
      102. |   Singapore    2005     117.4    1226866 |
      103. | New Zealand    2005      6061    1232927 |
      104. |     Vietnam    2005    4349.1    1237276 |
      105. |    Malaysia    2005      2467    1239743 |
           |------------------------------------------|
      106. | Phillipines    2005    5537.7    1245281 |
      107. |       Japan    2005     31577    1276858 |
      108. | South Korea    2005    1766.5    1278624 |
      109. |        Laos    2005     685.9    1279310 |
      110. |       China    2005    114951    1394261 |
           |------------------------------------------|
      111. |   Australia    2005    9344.6    1403606 |
      112. |    Thailand    2005    3138.7    1406744 |
      113. |   Indonesia    2006    5675.2    1412419 |
      114. |   Australia    2006    9500.5    1421920 |
      115. |     Vietnam    2006    4589.5    1426509 |
           |------------------------------------------|
      116. |    Thailand    2006    3456.1    1429966 |
      117. | New Zealand    2006      6062    1436028 |
      118. |   Sri Lanka    2006    1346.3    1437374 |
      119. | South Korea    2006    1942.6    1439316 |
      120. |        Laos    2006       686    1440002 |
           |------------------------------------------|
      121. |       China    2006    128770    1568772 |
      122. | Phillipines    2006    5537.7    1574310 |
      123. |       India    2006   38113.2    1612423 |
      124. |    Malaysia    2006    2571.8    1614995 |
      125. |       Japan    2006     32733    1647728 |
           |------------------------------------------|
      126. |   Singapore    2006     117.4    1647845 |
      127. |   Indonesia    2007    5781.8    1653627 |
      128. |   Sri Lanka    2007    1354.7    1654982 |
      129. |     Vietnam    2007    4992.6    1659975 |
      130. |   Australia    2007    9990.1    1669965 |
           |------------------------------------------|
      131. |    Malaysia    2007    2661.2    1672626 |
      132. | New Zealand    2007    6238.8    1678865 |
      133. | Phillipines    2007    5532.7    1684397 |
      134. |        Laos    2007       686    1685083 |
      135. |       India    2007   41780.9    1726864 |
           |------------------------------------------|
      136. |   Singapore    2007     117.4    1726982 |
      137. |       China    2007    146613    1873594 |
      138. |    Thailand    2007    3793.8    1877388 |
      139. | South Korea    2007    2022.1    1879410 |
      140. |       Japan    2007     32421    1911831 |
           |------------------------------------------|
      141. |       China    2008    174204    2086036 |
      142. |       India    2008   45173.7    2131209 |
      143. |    Malaysia    2008    2682.8    2133892 |
      144. |   Indonesia    2008    5856.8    2139749 |
      145. | Phillipines    2008    5539.2    2145288 |
           |------------------------------------------|
      146. |     Vietnam    2008      5995    2151283 |
      147. | South Korea    2008    2438.2    2153721 |
      148. |   Australia    2008   10126.1    2163847 |
      149. |    Thailand    2008    4040.3    2167888 |
      150. |        Laos    2008       686    2168574 |
           |------------------------------------------|
      151. |   Singapore    2008     117.8    2168692 |
      152. |   Sri Lanka    2008    1387.6    2170079 |
      153. |       Japan    2008     32909    2202988 |
      154. | New Zealand    2008    6407.9    2209396 |
      155. |     Vietnam    2009    7275.6    2216672 |
           |------------------------------------------|
      156. | Phillipines    2009    5572.8    2222244 |
      157. |       Japan    2009     33642    2255886 |
      158. |   Singapore    2009     130.3    2256017 |
      159. |   Indonesia    2009    6681.8    2262699 |
      160. |    Thailand    2009    4129.9    2266828 |
           |------------------------------------------|
      161. |   Australia    2009   10513.1    2277342 |
      162. |       China    2009    204976    2482318 |
      163. |       India    2009     47784    2530102 |
      164. |        Laos    2009      1850    2531952 |
      165. | New Zealand    2009      6573    2538525 |
           |------------------------------------------|
      166. |    Malaysia    2009    2784.8    2541309 |
      167. |   Sri Lanka    2009    1425.8    2542735 |
      168. | South Korea    2009    2683.1    2545418 |
      169. |        Laos    2010      2565    2547983 |
      170. | New Zealand    2010    6627.2    2554610 |
           |------------------------------------------|
      171. |   Singapore    2010     132.2    2554743 |
      172. | South Korea    2010    2870.7    2557613 |
      173. |   Sri Lanka    2010      1463    2559076 |
      174. |       China    2010    232655    2791731 |
      175. |    Thailand    2010    4214.3    2795946 |
           |------------------------------------------|
      176. | Phillipines    2010    5666.1    2801612 |
      177. |     Vietnam    2010    8765.5    2810377 |
      178. |       India    2010   51431.6    2861809 |
      179. |   Indonesia    2010    6834.5    2868643 |
      180. |       Japan    2010   36040.9    2904684 |
           |------------------------------------------|
      181. |    Malaysia    2010    2846.2    2907530 |
      182. |   Australia    2010   11125.1    2918656 |
      183. |    Malaysia    2011    3874.6    2922530 |
      184. | New Zealand    2011    6726.4    2929257 |
      185. |       China    2011    267095    3196351 |
           |------------------------------------------|
      186. |     Vietnam    2011     10193    3206544 |
      187. |    Thailand    2011    4466.2    3211010 |
      188. |   Sri Lanka    2011    1488.7    3212499 |
      189. | Phillipines    2011    5487.3    3217986 |
      190. |        Laos    2011    2571.3    3220558 |
           |------------------------------------------|
      191. | South Korea    2011    3369.6    3223927 |
      192. |   Australia    2011   12399.1    3236326 |
      193. |       Japan    2011   37412.5    3273739 |
      194. |   Singapore    2011     134.3    3273873 |
      195. |   Indonesia    2011    7112.6    3280986 |
           |------------------------------------------|
      196. |       India    2011   57141.1    3338127 |
      197. |   Sri Lanka    2012    1711.3    3339838 |
      198. | New Zealand    2012      6800    3346638 |
      199. | South Korea    2012    3962.7    3350601 |
      200. |    Malaysia    2012    4139.1    3354740 |
           |------------------------------------------|
      201. |   Australia    2012   13874.1    3368614 |
      202. |        Laos    2012    2978.6    3371593 |
      203. |    Thailand    2012    5103.2    3376696 |
      204. |       India    2012   60936.4    3437632 |
      205. |   Singapore    2012     138.5    3437771 |
           |------------------------------------------|
      206. | Phillipines    2012    5561.5    3443332 |
      207. |   Indonesia    2012    7450.7    3450783 |
      208. |       China    2012    299020    3749803 |
      209. |     Vietnam    2012     13665    3763468 |
      210. |       Japan    2012     38989    3802457 |
           |------------------------------------------|
      211. | South Korea    2013      5085    3807542 |
      212. |       India    2013   63862.4    3871404 |
      213. |       China    2013    357960    4229365 |
      214. |   Singapore    2013     143.7    4229509 |
      215. |   Indonesia    2013    8214.1    4237723 |
           |------------------------------------------|
      216. |    Thailand    2013      6115    4243838 |
      217. |   Sri Lanka    2013    1735.5    4245573 |
      218. |        Laos    2013      3234    4248807 |
      219. | New Zealand    2013      6890    4255697 |
      220. |   Australia    2013   14594.1    4270291 |
           |------------------------------------------|
      221. |     Vietnam    2013     14853    4285144 |
      222. |    Malaysia    2013    4843.1    4289987 |
      223. |       Japan    2013   46072.4    4336060 |
      224. | Phillipines    2013    5602.5    4341662 |
      225. |       Japan    2014     56088    4397750 |
           |------------------------------------------|
      226. |        Laos    2014    3298.3    4401049 |
      227. | Phillipines    2014    6000.6    4407049 |
      228. |       India    2014   70701.3    4477750 |
      229. | South Korea    2014    6735.2    4484486 |
      230. |       China    2014    411465    4895951 |
           |------------------------------------------|
      231. |    Malaysia    2014    5364.9    4901316 |
      232. |     Vietnam    2014     15208    4916524 |
      233. |    Thailand    2014    6826.5    4923350 |
      234. |   Indonesia    2014    8360.9    4931711 |
      235. |   Australia    2014   15937.1    4947648 |
           |------------------------------------------|
      236. |   Singapore    2014     161.5    4947810 |
      237. | New Zealand    2014      7131    4954941 |
      238. |   Sri Lanka    2014    1805.1    4956746 |
      239. |    Thailand    2015    7431.8    4964178 |
      240. |       China    2015    479108    5443285 |
           |------------------------------------------|
      241. | South Korea    2015    8225.8    5451511 |
      242. |       India    2015   77560.6    5529072 |
      243. |   Sri Lanka    2015    1819.9    5530892 |
      244. |   Singapore    2015     188.1    5531080 |
      245. |        Laos    2015    4000.2    5535080 |
           |------------------------------------------|
      246. |    Malaysia    2015    6787.8    5541868 |
      247. |     Vietnam    2015   16152.4    5558020 |
      248. |   Indonesia    2015    8455.5    5566476 |
      249. | New Zealand    2015      7170    5573646 |
      250. | Phillipines    2015    6303.7    5579949 |
           |------------------------------------------|
      251. |   Australia    2015   16729.1    5596679 |
      252. |       Japan    2015   66611.5    5663290 |
      253. |    Malaysia    2016    7286.9    5670577 |
      254. |       India    2016   90172.2    5760749 |
      255. | South Korea    2016    9575.7    5770325 |
           |------------------------------------------|
      256. |   Sri Lanka    2016      1863    5772188 |
      257. |   Indonesia    2016    8788.6    5780976 |
      258. |   Singapore    2016     254.5    5781231 |
      259. |    Thailand    2016    8897.2    5790128 |
      260. | Phillipines    2016    6961.6    5797090 |
           |------------------------------------------|
      261. |   Australia    2016   17653.7    5814743 |
      262. |       China    2016    541234    6355978 |
      263. |       Japan    2016   75446.9    6431424 |
      264. |        Laos    2016    5023.2    6436448 |
      265. | New Zealand    2016    7189.6    6443637 |
           |------------------------------------------|
      266. |     Vietnam    2016   17431.6    6461069 |
           +------------------------------------------+

      Comment


      • #4
        Farah:
        what about:
        Code:
        bysort year: egen tot_ric=total(ric)
        Kind regards,
        Carlo
        (Stata 18.0 SE)

        Comment


        • #5
          Carlo,

          Alright, i have sorted it now. Thanks a lot!

          Comment

          Working...
          X