楼主: Bi1ld
50612 11

[编程问题求助] stata处理数据提示type mismatch [推广有奖]

  • 0关注
  • 0粉丝

等待验证会员

小学生

64%

还不是VIP/贵宾

-

威望
0
论坛币
10 个
通用积分
1.0000
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
55 点
帖子
7
精华
0
在线时间
6 小时
注册时间
2019-3-9
最后登录
2019-4-9

楼主
Bi1ld 发表于 2019-3-9 22:28:38 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
命令如下:. *划分企业标准
. *0代表高科技产业,1代表非高科技产业
. gen industry= "1"
. destring industry,replace force
industry contains nonnumeric characters; replaced as byte
. destring ids_1,replace force
ids_1 already numeric; no replace
. replace industry= "0" if ids_1== "2710"|ids_1== "2720"
type mismatch
r(109);


industry的类型是byte, ids_1的类型是Int,
求大神指导

二维码

扫码加我 拉你入群

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

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

关键词:高科技产业 科技产业 高科技产 企业标准 高科技

回帖推荐

黃河泉 发表于8楼  查看完整内容

试试

沙发
Bi1ld 发表于 2019-3-9 22:43:12
  1. * Example generated by -dataex-. To install: ssc install dataex
  2. clear
  3. input byte industry int ids_1
  4. 1 3412
  5. 1 3412
  6. 1 3412
  7. 1 3412
  8. 1 3412
  9. 1 3412
  10. 1 3923
  11. 1 3923
  12. 1 3923
  13. 1 3923
  14. 1 3923
  15. 1 2631
  16. 1 2631
  17. 1 2631
  18. 1 2631
  19. 1 2631
  20. 1 2631
  21. 1 2631
  22. 1 2631
  23. 1 2631
  24. 1 2631
  25. 1 2631
  26. 1 3721
  27. 1 3721
  28. 1 3721
  29. 1 3721
  30. 1 3721
  31. 1 3721
  32. 1 3721
  33. 1 3721
  34. 1 2040
  35. 1 2040
  36. 1 2040
  37. 1 2040
  38. 1 2040
  39. 1 2040
  40. 1 2040
  41. 1 2040
  42. 1 3922
  43. 1 3922
  44. 1 3922
  45. 1 3922
  46. 1 4061
  47. 1 4061
  48. 1 3922
  49. 1 4061
  50. 1 3922
  51. 1 4061
  52. 1 3411
  53. 1 3411
  54. 1 3411
  55. 1 3090
  56. 1 3090
  57. 1 3090
  58. 1 2710
  59. 1 2710
  60. 1 2710
  61. 1 2710
  62. 1 4119
  63. 1 4119
  64. 1 4119
  65. 1 1810
  66. 1 1810
  67. 1 1810
  68. 1 1810
  69. 1 1810
  70. 1 1810
  71. 1 1810
  72. 1 1810
  73. 1 3230
  74. 1 3230
  75. 1 3230
  76. 1 3230
  77. 1 3230
  78. 1 3230
  79. 1 3230
  80. 1 3230
  81. 1 3230
  82. 1 3543
  83. 1 3543
  84. 1 3543
  85. 1 3543
  86. 1 3543
  87. 1 3543
  88. 1 3611
  89. 1 3611
  90. 1 3611
  91. 1 4061
  92. 1 4061
  93. 1 4090
  94. 1 4061
  95. 1 4061
  96. 1 4061
  97. 1 4061
  98. 1 4090
  99. 1 4061
  100. 1 4090
  101. 1 4042
  102. 1 4090
  103. 1 4042
  104. end
复制代码

藤椅
黃河泉 在职认证  发表于 2019-3-10 08:02:36
Bi1ld 发表于 2019-3-9 22:43
你给的资料有何问题?要做什么?请说明!

板凳
Bi1ld 发表于 2019-3-10 08:26:48
黃河泉 发表于 2019-3-10 08:02
你给的资料有何问题?要做什么?请说明!
[code]
. gen industry= "1"
. destring industry,replace force
industry contains nonnumeric characters; replaced as byte
. destring ids_1,replace force
ids_1 already numeric; no replace
. replace industry= "0" if ids_1== "2710"|ids_1== "2720"
type mismatch
r(109);
就是使用replace之后出现了type mismatch的问题,求解答,谢谢大神

报纸
Bi1ld 发表于 2019-3-10 08:26:55
黃河泉 发表于 2019-3-10 08:02
你给的资料有何问题?要做什么?请说明!
[code]
. gen industry= "1"
. destring industry,replace force
industry contains nonnumeric characters; replaced as byte
. destring ids_1,replace force
ids_1 already numeric; no replace
. replace industry= "0" if ids_1== "2710"|ids_1== "2720"
type mismatch
r(109);
就是使用replace之后出现了type mismatch的问题,求解答,谢谢大神

地板
黃河泉 在职认证  发表于 2019-3-10 09:10:56
Bi1ld 发表于 2019-3-10 08:26
[code]
. gen industry= "1"
. destring industry,replace force
我没兴趣看别人的程序,请说明给的资料 (你做的事与给的资料为何是两码事?) 有何问题?要做什么?

7
Bi1ld 发表于 2019-3-10 09:19:14
黃河泉 发表于 2019-3-10 09:10
我没兴趣看别人的程序,请说明给的资料 (你做的事与给的资料为何是两码事?) 有何问题?要做什么?
抱歉抱歉,给的资料就是举个例子,就是想把industry这一列根据ids_1的行业代码来转换一下,如果ids_1这一列的数字是3412或者3923的话,industry的数值就变成0

8
黃河泉 在职认证  发表于 2019-3-10 09:56:40
Bi1ld 发表于 2019-3-10 09:19
抱歉抱歉,给的资料就是举个例子,就是想把industry这一列根据ids_1的行业代码来转换一下,如果ids_1这一 ...
试试
  1. replace industry = 0 if ids_1 == 3412 |ids_1 == 3923
复制代码

9
Bi1ld 发表于 2019-3-10 16:39:07
黃河泉 发表于 2019-3-10 09:56
试试
把引号去掉可以运行了
感谢大神

10
黃河泉 在职认证  发表于 2019-3-10 16:56:02
Bi1ld 发表于 2019-3-10 16:39
把引号去掉可以运行了
感谢大神
没错,这里是数字,若是文字的话,你原先作法就是对的!

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

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2026-1-3 00:23