楼主: bwhbwh
1960 8

[数据管理求助] 如何转成宽形数据 [推广有奖]

  • 1关注
  • 27粉丝

灵长类

已卖:3160份资源

院士

3%

还不是VIP/贵宾

-

威望
0
论坛币
8245 个
通用积分
282.0311
学术水平
76 点
热心指数
99 点
信用等级
53 点
经验
40255 点
帖子
1018
精华
1
在线时间
4088 小时
注册时间
2004-7-4
最后登录
2025-12-26

楼主
bwhbwh 发表于 2012-4-7 14:41:17 |AI写论文
5论坛币
如何将下列数据转成宽形?宽形见表二
表一   

t

go

country

1995

1

372

1995

1

410

1995

1

417

1995

2

36

1995

2

344

1995

2

410

1995

2

446

1995

2

554

1995

2

702

1995

2

757

1995

3

392

1995

3

711

1995

3

554

1995

4

124

1995

4

392

1995

4

408

1995

4

757


表二

t

1

2

3

4

1995

 

36

 

 

1995

 

 

 

124

1995

 

344

 

 

1995

372

 

 

 

1995

 

 

392

392

1995

 

 

 

408

1995

410

410

 

 

1995

417

 

 

 

1995

 

446

 

 

1995

 

554

554

554

1995

 

702

 

 

1995

 

 

711

 

1995

 

757

 

 

1995

 

764

 

 


最佳答案

sungmoo 查看完整内容

bys t (country go): g i=_n reshape wide country,i(t i) j(go) egen c=rowtotal(country*) collapse (sum)country*,by(t c)
关键词:Country Count Try 数据 如何

沙发
sungmoo 发表于 2012-4-7 14:41:18
bys t (country go): g i=_n
reshape wide country,i(t i) j(go)
egen c=rowtotal(country*)
collapse (sum)country*,by(t c)

藤椅
hplcdadong 发表于 2012-4-7 18:12:16
gen id=_n
reshape wide country, i(id) j(go)

板凳
bwhbwh 发表于 2012-4-7 20:14:46
hplcdadong 发表于 2012-4-7 18:12
gen id=_n
reshape wide country, i(id) j(go)
兄弟,不行啊

报纸
bwhbwh 发表于 2012-4-7 20:21:43
hplcdadong 发表于 2012-4-7 18:12
gen id=_n
reshape wide country, i(id) j(go)
要配对的

地板
hplcdadong 发表于 2012-4-8 02:06:38
egen id2=tag(country)
egen id3=rank(country) if id2==1
bysort country: gen id1=id3[1]
drop id2 id3
reshape wide country, i(id1) j(go)

7
hplcdadong 发表于 2012-4-8 02:15:56
Sorry, should be this:

sort country
egen id2=tag(country)
egen id3=rank(country) if id2==1
bysort country: gen id1=id3[1]
drop id2 id3
reshape wide country, i(id1) j(go)

8
bwhbwh 发表于 2012-4-8 10:28:52
感谢万分

9
liusukun 发表于 2013-6-21 16:29:55

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

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