楼主: Lucifer_sad
907 1

[数据管理求助] 怎么把一年的数据和几年的数据匹配 [推广有奖]

  • 0关注
  • 1粉丝

等待验证会员

高中生

75%

还不是VIP/贵宾

-

威望
0
论坛币
0 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
161 点
帖子
12
精华
0
在线时间
48 小时
注册时间
2017-11-29
最后登录
2022-5-15

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
----------------------- copy starting from the next line -----------------------
  1. * Example generated by -dataex-. To install: ssc install dataex
  2. clear
  3. input str7 code int year
  4. "       000004" 2013
  5. "       000004" 2015
  6. "       000004" 2016
  7. "       000005" 2016
  8. "       000006" 2015
  9. "       000007" 2016
  10. "       000008" 2013
  11. "       000008" 2015
  12. "       000009" 2014
  13. "       000012" 2014
  14. "       000012" 2016
  15. "       000014" 2014
  16. "       000016" 2013
  17. "       000016" 2016
  18. "       000017" 2014
  19. "       000019" 2015
  20. "       000020" 2015
  21. "       000021" 2015
  22. "       000021" 2016
  23. "       000023" 2013
  24. end
复制代码
------------------ copy up to and including the previous line ------------------



----------------------- copy starting from the next line -----------------------
  1. * Example generated by -dataex-. To install: ssc install dataex
  2. clear
  3. input str15 code int year byte industry
  4. "000002" 2016 3
  5. "000004" 2015 5
  6. "000005" 2016 2
  7. "000006" 2016 3
  8. "000007" 2016 3
  9. "000008" 2016 5
  10. "000009" 2015 4
  11. "000010" 2016 3
  12. "000011" 2016 3
  13. "000012" 2016 5
  14. "000014" 2016 3
  15. "000016" 2016 5
  16. "000017" 2016 5
  17. "000018" 2016 4
  18. "000019" 2016 5
  19. "000020" 2015 5
  20. "000021" 2015 5
  21. "000022" 2016 2
  22. "000023" 2015 5
  23. "000024" 2015 3
  24. end
复制代码
------------------ copy up to and including the previous line ------------------


我想把industry匹配到第一个数据上,然后只有code一样,那么该公司其他年份的industry也都一样
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝


沙发
黃河泉 在职认证  发表于 2017-12-19 15:36:04 |只看作者 |坛友微信交流群
1. 你者两个档都是多年的!2. 上面档的部分要改一下
  1. input str17 code int year
复制代码
。3.
  1. * Example generated by -dataex-. To install: ssc install dataex
  2. clear
  3. input str15 code int year
  4. "       000004" 2013
  5. "       000004" 2015
  6. "       000004" 2016
  7. "       000005" 2016
  8. "       000006" 2015
  9. "       000007" 2016
  10. "       000008" 2013
  11. "       000008" 2015
  12. "       000009" 2014
  13. "       000012" 2014
  14. "       000012" 2016
  15. "       000014" 2014
  16. "       000016" 2013
  17. "       000016" 2016
  18. "       000017" 2014
  19. "       000019" 2015
  20. "       000020" 2015
  21. "       000021" 2015
  22. "       000021" 2016
  23. "       000023" 2013
  24. end

  25. gen id = strtrim(code)
  26. tempfile a
  27. save `a'

  28. * Example generated by -dataex-. To install: ssc install dataex
  29. clear
  30. input str15 code int year byte industry
  31. "000002" 2016 3
  32. "000004" 2015 5
  33. "000005" 2016 2
  34. "000006" 2016 3
  35. "000007" 2016 3
  36. "000008" 2016 5
  37. "000009" 2015 4
  38. "000010" 2016 3
  39. "000011" 2016 3
  40. "000012" 2016 5
  41. "000014" 2016 3
  42. "000016" 2016 5
  43. "000017" 2016 5
  44. "000018" 2016 4
  45. "000019" 2016 5
  46. "000020" 2015 5
  47. "000021" 2015 5
  48. "000022" 2016 2
  49. "000023" 2015 5
  50. "000024" 2015 3
  51. end

  52. gen id = strtrim(code)
  53. merge 1:1 id year using `a'
  54. sort id year
复制代码

使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jltj
拉您入交流群

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

GMT+8, 2024-4-28 15:32