<address id="b53l5"><progress id="b53l5"><font id="b53l5"></font></progress></address>

      <address id="b53l5"></address>
      <sub id="b53l5"></sub><sub id="b53l5"><meter id="b53l5"><cite id="b53l5"></cite></meter></sub>
        <sub id="b53l5"><progress id="b53l5"></progress></sub>
        <listing id="b53l5"><menuitem id="b53l5"></menuitem></listing>
        <sub id="b53l5"><progress id="b53l5"><font id="b53l5"></font></progress></sub><thead id="b53l5"><meter id="b53l5"></meter></thead>

          <track id="b53l5"></track>

              楼主: 沉默的烽火
              354 6

              [编程问题求助] stata 对于双边数据怎样保留唯一的组合 [推广有奖]

              • 4关注
              • 7粉丝

              博?#21487;?/p>

              74%

              还不是VIP/贵宾

              -
              楼主
              沉默的烽火 学生?#29616;? title=  发表于 2019-2-21 01:34:18 |只看作者 |倒序
              以进出口为例£¬A对B的出口恰好就是B对A的进口£¬所以按照贸易顺差/逆差来看的话A国和B国的对外贸易差额绝对值其实是一样的¡£现在我希望保留唯一的配对£¨比如B-A和A-B视为一对£©£¬请问在stata里面要怎么操作才能实现啊?#35838;易约合?#20102;几个方法都不行£¨比如对A.B分别赋值然后看A+B的值之类的£¬仔细想想发现不对...£©有代码最好£¨编程苦手£¬感觉写的命令不简洁£©£¬说个思路也可以£¬请大神指点

              出口国

              进口国

              出口额

              贸易差额

              A

              B

              2

              -1

              A

              C

              1

              1

              B

              A

              3

              1

              B

              C

              1

              1

              C

              A

              0

              -1

              C

              B

              0

              -1



              关键?#21097;?a href="http://www.9062865.com/t/6442.html" target="_blank" rel="nofollow">Stata tata 贸易差额 贸易顺差 怎么操作

              stata SPSS
              沙发
              黃河泉 在职?#29616;? title=  发表于 2019-2-21 07:47:38 |只看作者
              你若要问程序£¬永远附上相关资?#24076;?#33509;附上资?#24076;?#27704;远用 dataex 印出资料¡£
              1.        先 ssc install dataex (并见说明)£¬将原始 Stata 资?#29616;?#20855;有¡±代表性¡±的一部分资料列出£¬以供有意回答者实验之用£¬并能提供具体操作指令¡£
              2.        并请参考 http://www.jianshu.com/p/9870080fe769,  http://www.9062865.com/thread-5048204-1-1.html, 与 http://www.9062865.com/thread-5917273-1-1.html¡£
              已有 1 人评分经验 收起 理由
              葫芦娃大王 + 10 精彩帖子

              总评分: 经验 + 10   查看全部评分

              回复

              使用道具 举报

              藤椅
              沉默的烽火 学生?#29616;? title=  发表于 2019-2-21 10:46:47 |只看作者
              本帖最后由 沉默的烽火 于 2019-2-21 11:00 编辑
              黃河泉 发表于 2019-2-21 07:47
              你若要问程序£¬永远附上相关资?#24076;?#33509;附上资?#24076;?#27704;远用 dataex 印出资料¡£
              1.        先 ssc install dataex (并见 ...
              ?#35780;?#24072;您好£¬抱歉还没有养成用dataex的习惯£¬所以之前只是按照想法描述了一下大概数据的形态¡£
              这是?#20040;?#30721;截取出来的数据样本£¬origin就是出口国£¬dest是目的国£¬index使我算的一个指数£¬类似于贸易差额这样的东西¡£
              1. * Example generated by -dataex-. To install: ssc install dataex
              2. clear
              3. input str3(origin dest) float(index_bilateral year)
              4. "CHN" "BGR"  25.245697 2010
              5. "CHN" "RUS" -.26786003 2004
              6. "CHN" "IND"   15.62117 2008
              7. "CHN" "IND"   6.619596 2006
              8. "CHN" "CYP"   65.14904 2003
              9. "CHN" "PRT"  28.602924 2011
              10. "CHN" "BGR"  16.159151 2013
              11. "CHN" "EST"   43.11666 2012
              12. "CHN" "MLT"   47.30183 2008
              13. "CHN" "LVA"   51.74584 2005
              14. "CHN" "IDN"  16.247213 2014
              15. "CHN" "CZE"  34.753216 2008
              16. "CHN" "HUN"   37.37414 2000
              17. "CHN" "KOR"  -18.88718 2001
              18. "CHN" "CZE"  17.311008 2013
              19. "CHN" "RUS"   5.484401 2005
              20. "CHN" "EST"   42.96254 2006
              21. "CHN" "TUR"   50.51025 2014
              22. "CHN" "LTU"   48.40796 2006
              23. "CHN" "LTU"   50.13712 2008
              24. "CHN" "CZE"  24.503586 2011
              25. "CHN" "KOR"   -26.1602 2013
              26. "CHN" "SVK"  -4.946331 2013
              27. "CHN" "IDN"  -9.215469 2001
              28. "CHN" "MEX"   58.31996 2004
              29. "CHN" "HUN"   42.35766 2003
              30. "CHN" "KOR"   -27.2578 2004
              31. "CHN" "POL"   35.22688 2012
              32. "CHN" "CYP"   52.51056 2012
              33. "CHN" "RUS"  -23.19418 2000
              34. "CHN" "CYP"   57.22584 2004
              35. "CHN" "SVK"  35.143818 2001
              36. "CHN" "BGR"   48.62837 2000
              37. "CHN" "RUS"  23.311113 2010
              38. "CHN" "TUR"   40.50524 2010
              39. "CHN" "SVK"  24.040916 2006
              40. "CHN" "RUS"  25.840374 2008
              41. "CHN" "MEX"   57.34701 2005
              42. "CHN" "SVK"  4.5704594 2010
              43. "CHN" "CYP"   63.87872 2009
              44. "CHN" "LVA"    41.2198 2004
              45. "CHN" "KOR"  -23.98084 2012
              46. "CHN" "MLT"   26.56485 2002
              47. "CHN" "BEL"   4.807569 2003
              48. "CHN" "TUR"   51.87334 2008
              49. "CHN" "GRC"   48.62494 2013
              50. "CHN" "IDN" -.51416165 2012
              51. "CHN" "CZE"  14.584755 2014
              52. "CHN" "HUN"  34.845596 2002
              53. "CHN" "POL"  32.281773 2001
              54. "CHN" "CZE"   26.69204 2010
              55. "CHN" "MLT"   60.83664 2014
              56. "CHN" "PRT"   43.49453 2007
              57. "CHN" "IDN"    7.19298 2008
              58. "CHN" "GRC"   55.29412 2010
              59. "CHN" "EST"   58.36507 2002
              60. "CHN" "HUN"   27.52004 2006
              61. "CHN" "SVN"   39.25492 2007
              62. "CHN" "SVN"  32.444096 2010
              63. "CHN" "SVK"  -4.403139 2014
              64. "CHN" "SVK"  4.2479577 2003
              65. "CHN" "LTU"   48.02407 2007
              66. "CHN" "KOR" -26.778866 2010
              67. "CHN" "BRA" -16.774914 2001
              68. "CHN" "PRT"  22.120983 2014
              69. "CHN" "POL"   34.62191 2002
              70. "CHN" "CYP"   68.21292 2002
              71. "CHN" "CZE"  24.281513 2002
              72. "CHN" "BRA" -24.257875 2002
              73. "CHN" "HUN"  -.3747167 2010
              74. "CHN" "HUN"   26.74776 2008
              75. "CHN" "BGR"   68.55055 2006
              76. "CHN" "MEX"   53.34143 2014
              77. "CHN" "BGR"   44.87311 2003
              78. "CHN" "HRV"   6.029083 2002
              79. "CHN" "LTU"  21.262976 2001
              80. "CHN" "KOR" -24.096216 2014
              81. "CHN" "KOR"  -6.164859 2008
              82. "CHN" "GRC"   64.14749 2007
              83. "CHN" "SVK"  25.626314 2005
              84. "CHN" "LVA"   60.10111 2007
              85. "CHN" "TUR"   54.39251 2006
              86. "CHN" "BGR"   58.43769 2001
              87. "CHN" "IDN"  -9.743893 2002
              88. "CHN" "POL"   40.53851 2009
              89. "CHN" "BGR"   61.54499 2008
              90. "CHN" "LVA"  30.358263 2001
              91. "CHN" "HUN"  -1.405918 2012
              92. "CHN" "IDN"  -2.970981 2007
              93. "CHN" "HUN"   5.198897 2014
              94. "CHN" "CZE"  28.565166 2006
              95. "CHN" "LTU"   21.54196 2002
              96. "CHN" "EST"   68.44804 2001
              97. "CHN" "BEL"   3.225987 2013
              98. "CHN" "SVN"  34.447018 2011
              99. "CHN" "RUS"  11.041714 2006
              100. "CHN" "LTU"  33.574306 2009
              101. "CHN" "MEX"    62.5219 2006
              102. "CHN" "HRV" -12.727107 2000
              103. "CHN" "SVN"   27.55047 2001
              104. "BEL" "CHN"   .8011382 2012
              105. "BEL" "CHN"   -13.3949 2004
              106. "BEL" "CHN" -15.197672 2000
              107. "BEL" "CHN"  -4.807569 2003
              108. "BEL" "CHN"  -22.55604 2006
              109. "BEL" "CHN"  -3.225987 2013
              110. "BEL" "CHN"  -11.47142 2009
              111. "BEL" "CHN"   .9251509 2002
              112. "BEL" "CHN"  -9.647018 2001
              113. "BEL" "CHN"  -4.850701 2014
              114. "BEL" "CHN"  -7.969518 2010
              115. "BEL" "CHN" -21.128284 2007
              116. "BEL" "CHN" -18.861422 2005
              117. "BEL" "CHN"  -5.933108 2011
              118. "BEL" "CHN"  -25.02423 2008
              119. "BGR" "CHN"  -58.43769 2001
              120. "BGR" "CHN"  -46.04298 2009
              121. "BGR" "CHN" -25.245697 2010
              122. "BGR" "CHN"  -56.58496 2005
              123. "BGR" "CHN"  -68.55055 2006
              124. "BGR" "CHN"  -46.10373 2004
              125. "BGR" "CHN" -16.159151 2013
              126. "BGR" "CHN"  -61.54499 2008
              127. "BGR" "CHN"  -48.62837 2000
              128. "BGR" "CHN"  -22.00906 2011
              129. "BGR" "CHN"  -47.20781 2002
              130. "BGR" "CHN" -17.001524 2014
              131. "BGR" "CHN"  -59.63894 2007
              132. "BGR" "CHN"  -21.91966 2012
              133. "BGR" "CHN"  -44.87311 2003
              134. "BRA" "CHN"  24.257875 2002
              135. "BRA" "CHN"  13.162673 2011
              136. "BRA" "CHN"  15.624968 2000
              137. "BRA" "CHN"  28.500885 2003
              138. "BRA" "CHN"   5.904176 2010
              139. "BRA" "CHN"  16.774914 2001
              140. "BRA" "CHN"  18.910135 2005
              141. "BRA" "CHN"   6.474211 2007
              142. "BRA" "CHN"   10.03562 2006
              143. "BRA" "CHN"   9.583493 2012
              144. "BRA" "CHN" -1.0021992 2008
              145. "BRA" "CHN"   4.442032 2013
              146. "BRA" "CHN"  21.865746 2004
              147. "BRA" "CHN"  11.803807 2009
              148. "BRA" "CHN" -2.3279502 2014
              149. "CYP" "CHN"  -68.21292 2002
              150. "CYP" "CHN"  -73.69014 2007
              151. "CYP" "CHN"  -66.83552 2006
              152. "CYP" "CHN"  -66.31237 2000
              153. "CYP" "CHN"  -57.22584 2004
              154. "CYP" "CHN"  -49.63297 2013
              155. "CYP" "CHN"  -58.10071 2001
              156. "CYP" "CHN"  -68.57891 2010
              157. "CYP" "CHN"   -63.3471 2005
              158. "CYP" "CHN"  -54.56297 2014
              159. "CYP" "CHN"  -71.86724 2008
              160. "CYP" "CHN"  -63.87872 2009
              161. "CYP" "CHN"  -52.51056 2012
              162. "CYP" "CHN"  -59.69622 2011
              163. "CYP" "CHN"  -65.14904 2003
              164. "CZE" "CHN" -24.281513 2002
              165. "CZE" "CHN" -34.032505 2007
              166. "CZE" "CHN" -14.584755 2014
              167. "CZE" "CHN" -17.311008 2013
              168. "CZE" "CHN" -17.492489 2001
              169. "CZE" "CHN"  -27.75855 2005
              170. "CZE" "CHN" -28.565166 2006
              171. "CZE" "CHN" -34.753216 2008
              172. "CZE" "CHN"  -23.58339 2004
              173. "CZE" "CHN" -11.225542 2000
              174. "CZE" "CHN"  -26.69204 2010
              175. "CZE" "CHN" -24.503586 2011
              176. "CZE" "CHN" -24.731274 2003
              177. "CZE" "CHN"  -28.88364 2009
              178. "CZE" "CHN" -19.054138 2012
              179. "EST" "CHN"  -39.77054 2005
              180. "EST" "CHN"  -39.66985 2014
              181. "EST" "CHN"  -42.98664 2008
              182. "EST" "CHN"  -42.96254 2006
              183. "EST" "CHN"  -58.36507 2002
              184. "EST" "CHN" -28.522646 2009
              185. "EST" "CHN"  -68.44804 2001
              186. "EST" "CHN"  -49.15324 2003
              187. "EST" "CHN"  -32.25482 2010
              188. "EST" "CHN" -30.581184 2013
              189. "EST" "CHN"  -42.99669 2000
              190. "EST" "CHN" -36.860653 2011
              191. "EST" "CHN"  -47.77432 2007
              192. "EST" "CHN"  -44.49921 2004
              193. "EST" "CHN"  -43.11666 2012
              194. "GRC" "CHN"  -65.65321 2008
              195. "GRC" "CHN"  -53.34895 2001
              196. "GRC" "CHN"  -47.14865 2003
              197. "GRC" "CHN"  -44.98263 2012
              198. "GRC" "CHN"  -50.84057 2014
              199. "GRC" "CHN"  -50.93797 2002
              200. "GRC" "CHN"  -55.27709 2006
              201. "GRC" "CHN" -37.631474 2004
              202. "GRC" "CHN"  -55.29412 2010
              203. "GRC" "CHN"  -53.39635 2011
              204. end
              复制代码

              ------------------ copy up to and including the previous line ------------------



              希望能得到您的指导£¬谢谢
              回复

              使用道具 举报

              板凳
              黃河泉 在职?#29616;? title=  发表于 2019-2-21 11:36:53 |只看作者
              沉默的烽火 发表于 2019-2-21 10:46
              ?#35780;?#24072;您好£¬抱歉还没有养成用dataex的习惯£¬所以之前只是按照想法描述了一下大概数据的形态¡£
              这是?#20040;?...
              我帮你问问看!
              回复

              使用道具 举报

              报纸
              黃河泉 在职?#29616;? title=  发表于 2019-2-21 15:57:05 |只看作者
              沉默的烽火 发表于 2019-2-21 10:46
              ?#35780;?#24072;您好£¬抱歉还没有养成用dataex的习惯£¬所以之前只是按照想法描述了一下大概数据的形态¡£
              这是?#20040;?...
              根据 David Benson 建议£¬请先 ssc install multencode 并试试
              1. sort origin dest year
              2. bysort origin dest (year): gen n = _n
              3. multencode origin dest, gen(orig_id dest_id)
              4. gen dyad_id = cond(orig_id < dest_id, string(orig_id) + " " + string(dest_id), string(dest_id) + " " + string(orig_id))
              5. egen dyad = group(dyad_id), label
              6. duplicates drop dyad year, force
              7. sort origin dest year
              复制代码
              已有 1 人评分经验 论坛币 收起 理由
              葫芦娃大王 + 10 + 10 精彩帖子

              总评分: 经验 + 10  论坛币 + 10   查看全部评分

              回复

              使用道具 举报

              地板
              沉默的烽火 学生?#29616;? title=  发表于 2019-2-21 22:38:18 |只看作者
              黃河泉 发表于 2019-2-21 15:57
              根据 David Benson 建议£¬请先 ssc install multencode 并试试
              真的十分?#34892;?#24744;£¨也?#34892;»david benson£©£¬这个命令可以解决我的问题£¬多向您学习£¡
              回复

              使用道具 举报

              7
              黃河泉 在职?#29616;? title=  发表于 2019-2-22 08:55:54 |只看作者
              沉默的烽火 发表于 2019-2-21 22:38
              真的十分?#34892;?#24744;£¨也?#34892;»david benson£©£¬这个命令可以解决我的问题£¬多向您学习£¡
              请看看更 brilliant 之建议£ºhttp://www.9062865.com/thread-6937277-1-1.html¡£
              回复

              使用道具 举报

              您需要登?#24049;?#25165;可以回帖 登录 | 我要注册

              京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问?#21644;?#36827;律师 知识产权保护声明   免责及隐私声明

              GMT+8, 2019-4-21 16:06
              Á¬ÂëÌØ´®
              <address id="b53l5"><progress id="b53l5"><font id="b53l5"></font></progress></address>

                  <address id="b53l5"></address>
                  <sub id="b53l5"></sub><sub id="b53l5"><meter id="b53l5"><cite id="b53l5"></cite></meter></sub>
                    <sub id="b53l5"><progress id="b53l5"></progress></sub>
                    <listing id="b53l5"><menuitem id="b53l5"></menuitem></listing>
                    <sub id="b53l5"><progress id="b53l5"><font id="b53l5"></font></progress></sub><thead id="b53l5"><meter id="b53l5"></meter></thead>

                      <track id="b53l5"></track>

                          <address id="b53l5"><progress id="b53l5"><font id="b53l5"></font></progress></address>

                              <address id="b53l5"></address>
                              <sub id="b53l5"></sub><sub id="b53l5"><meter id="b53l5"><cite id="b53l5"></cite></meter></sub>
                                <sub id="b53l5"><progress id="b53l5"></progress></sub>
                                <listing id="b53l5"><menuitem id="b53l5"></menuitem></listing>
                                <sub id="b53l5"><progress id="b53l5"><font id="b53l5"></font></progress></sub><thead id="b53l5"><meter id="b53l5"></meter></thead>

                                  <track id="b53l5"></track>