楼主: gainend
7046 8

变量合并问题 [推广有奖]

  • 0关注
  • 2粉丝

教授

18%

还不是VIP/贵宾

-

威望
0
论坛币
27351 个
通用积分
0.3765
学术水平
3 点
热心指数
3 点
信用等级
0 点
经验
15858 点
帖子
341
精华
0
在线时间
2062 小时
注册时间
2009-12-13
最后登录
2025-10-13

楼主
gainend 发表于 2012-10-17 15:26:15 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
国泰安数据库中,一个是:Stkcd        Trdynt        Indcd        T60200
000001        2003        I01        0.16
000002        2003        J01        0.39
000004        2003        C8501        0.05
000005        2003        M        0.003
000006        2003        J01        -1.15
000007        2003        J01        0.1
000008        2003        G87        0.013
000009        2003        M        0.01
000010        2003        M        0.05
000011        2003        M        0.142
000012        2003        C61        0.3
另一个是:
Stkcd        Trdynt        Yclsprc
000001        2003        8.51
000001        2004        6.59
000001        2005        6.14
000001        2006        14.47
000001        2007        38.6
000001        2008        9.46
000001        2009        24.37
000001        2010        15.79
000002        2003        6.54
000002        2004        5.26
000002        2005        4.31
000002        2006        15.44
000002        2007        28.84
000002        2008        6.45
000002        2009        10.81
000002        2010        8.22
000004        2003        8.38
前一个怎样和后一个实现merge,我做了许多遍结果都是:variables stkcd trdynt do not uniquely identify observations in the master data,求助!
二维码

扫码加我 拉你入群

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

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

关键词:变量合并 observations observation Variables Variable 数据库 国泰

沙发
sungmoo 发表于 2012-10-17 15:32:45
(问法不妥)

想合并成什么样的结果,应该是楼主首先要告诉大家的。

藤椅
gainend 发表于 2012-10-17 15:37:04
面板的那种

板凳
fgleric 发表于 2012-10-18 00:06:39
assume you give data a and b
a is firm's characteristics, constant among 2003-2008
b is firm's annually data

clear
use a
sort Stkcd
save,replace
use b,clear
sort Stkcd
save,replace
use a,clear
merger 1:m Stkcd using b
save c

c should be panel if b is 2003-2008 for each firm.

报纸
gainend 发表于 2012-10-18 10:42:25
但软件老实说无法找到对应的 stkcd

地板
ywh19860616 发表于 2012-10-18 10:46:32
gainend 发表于 2012-10-18 10:42
但软件老实说无法找到对应的 stkcd
与其这样反复提问,何不上传你的样本数据
让别人试试。
一份耕耘,一份收获。

7
gainend 发表于 2012-10-18 10:55:55
我一个文件的有些股票代码,在第二个文件里面没有,是不是排列顺序是完全一致,才能合并成功吗

8
大白菜2012 发表于 2012-10-18 10:58:30
fgleric 发表于 2012-10-18 00:06
assume you give data a and b
a is firm's characteristics, constant among 2003-2008
b is firm's ann ...
i guess Stkcd is not a unique id in either files.


clear
use a
gen id=stkcd+year   //but this one can work as a unique id; say, both are string variables
sort id
save,replace

use b,clear
gen id=stkcd+year
sort id
save,replace

use a,clear
merger 1:1 id using b    // i think it should be 1:1, right?
save c
元芳,侬怎么L00K?

9
zhuosn 发表于 2017-12-28 19:14:28
提示: 作者被禁止或删除 内容自动屏蔽

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

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2025-12-31 15:47