全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件 Stata专版
4570 5
2017-06-02
如题,举个栗子:code为001时,a 值出现次数最多的值为1 ,如何生成新的变量b,使得当code为001时b的值为1?求各位大神指教,谢谢。
code    a      b
001    1       1
001    2       1
001    3       1
001    1       1
001    1       1
002    6       6
002     .       6
002     .       6
003    3       3
003    2       3
003    .        3
003    3       3

二维码

扫码加我 拉你入群

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

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

全部回复
2017-6-2 17:20:27
Hope this piece of code works. Good luck. However, I would remind you that your original data might be more complicated than what you showed here, so be careful about the identifier of subjects.
复制代码
二维码

扫码加我 拉你入群

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

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

2017-6-2 18:33:36
逍遥梦蝶 发表于 2017-6-2 17:20
Hope this piece of code works. Good luck. However, I would remind you that your original data might  ...
Well thank you very much for helping me solve this problem. Although the realistic condition may a bit more complicated,the method you offered above could always help me to think
二维码

扫码加我 拉你入群

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

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

2017-6-4 08:20:23
你要求的就是众数 (mode),试试
复制代码
二维码

扫码加我 拉你入群

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

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

2017-6-4 10:45:14
黃河泉 发表于 2017-6-4 08:20
你要求的就是众数 (mode),试试
好像也可以,谢谢您热心的解答
二维码

扫码加我 拉你入群

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

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

2017-6-4 10:45:19
黃河泉 发表于 2017-6-4 08:20
你要求的就是众数 (mode),试试
好像也可以,谢谢您热心的解答
二维码

扫码加我 拉你入群

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

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

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群