请教各位,我现在有下面左边一组数据,即有8家公司在2011年12月31日的account值,我想要把每一家公司的account加总出来,最后得到stkcd\trddt\tot-account这样的数据,即右边的样式。这个用state要怎么做呀?
stkcd trddt account 怎么变成? stkcd trddt tot-acc
000001 20111231 0 000001 20111231 2
000001 20111231 1 000002 20111231 0
000001 20111231 1 000004 20111231 1
000001 20111231 0 000005 20111231 0
000001 20111231 0 000006 20111231 1
000001 20111231 0 000007 20111231 0
000001 20111231 0 000008 20111231 0
000001 20111231 0
000002 20111231 0
000002 20111231 0
000002 20111231 0
000002 20111231 0
000004 20111231 0
000004 20111231 1
000004 20111231 0
000005 20111231 0
000005 20111231 0
000005 20111231 0
000005 20111231 0
000005 20111231 0
000006 20111231 0
000006 20111231 1
000006 20111231 0
000007 20111231 0
000007 20111231 0
000007 20111231 0
000008 20111231 0
000008 20111231 0
000008 20111231 0
本来自己想的笨方法,
egen ac= total(account) if stkcd==000001
egen ac2= total( account) if stkcd==000002
replace ac=ac2 if stkcd==000002
. egen ac4= total( account) if stkcd==000004
. replace ac=ac4 if stkcd==000004
。。。。。。。
然后就这么循环下去,但是我有3000多家公司。。。
我也不会做 循环的 命令,好痛苦,想了一天了,不知道该怎么做,请大家帮帮忙。


雷达卡



京公网安备 11010802022788号







