全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件 Stata专版
2732 4
2012-04-24
有这样一个变量(字符型)
0008
0008
A111
A111
0222
0222
B77777
B77777
...
如何把这个变量变成面板的idcode呀?
即变成下面这个形式
1
1
2
2
3
3
4
4
谢谢好心人!随手写个命令告诉一下吧!谢谢啦谢谢!

...
二维码

扫码加我 拉你入群

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

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

全部回复
2012-4-24 18:15:41
顶起来!
二维码

扫码加我 拉你入群

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

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

2012-4-24 18:52:52
egen idcode=group( 变量)



       group(varlist) [, missing label lname(name) truncate(num)]
            may not be combined with by.  It creates one variable taking on values 1, 2, ...
            for the groups formed by varlist.  varlist may contain numeric variables, string
            variables, or a combination of the two.  The order of the groups is that of the
            sort order of varlist.  missing indicates that missing values in varlist
            (either . or "") are to be treated like any other value when assigning groups,
            instead of as missing values being assigned to the group missing.  The label
            option returns integers from 1 up according to the distinct groups of varlist in
            sorted order.  The integers are labeled with the values of varlist or the value
            labels, if they exist.  lname() specifies the name to be given to the value label
            created to hold the labels; lname() implies label.  The truncate() option
            truncates the values contributed to the label from each variable in varlist to
            the length specified by the integer argument num.  The truncate option cannot be
            used without specifying the label option.  The truncate option does not change
            the groups that are formed; it changes only their labels.

二维码

扫码加我 拉你入群

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

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

2012-4-24 18:59:01
egen idcode=group(x)
二维码

扫码加我 拉你入群

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

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

2012-4-24 22:03:14
谢谢楼上两位啦!原来是版主!失敬失敬!
二维码

扫码加我 拉你入群

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

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

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

说点什么

分享

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