请选择 进入手机版 | 继续访问电脑版
楼主: lizhewenbei
13594 17

请教大神们,怎样剔除第 i家公司之后,计算同行业、同年度的其他公司ROA平均值? [推广有奖]

  • 15关注
  • 5粉丝

副教授

36%

还不是VIP/贵宾

-

威望
0
论坛币
309 个
通用积分
11.4770
学术水平
4 点
热心指数
13 点
信用等级
5 点
经验
9699 点
帖子
609
精华
0
在线时间
496 小时
注册时间
2008-2-6
最后登录
2024-1-9

lizhewenbei 学生认证  发表于 2014-11-29 21:04:24 |显示全部楼层 |坛友微信交流群
相似文件 换一批

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
请教大神们:
        下面这个工作该怎么做?怎样剔除第 i家公司之后,计算同行业、同年度的其他公司ROA平均值?
        相关的文献截图如下。万谢!!!

1.jpg


我想用宏命令,基于如下这个方式进行改变,但是结果完全不是自己想要的。请大神把脉!

proc sort data=a;by stkcd year;run;

data a1;set a;
by stkcd;
retain num 0; num=num;/*num=num+0的省略形式*/
if first.stkcd then num=num+1;
run;

proc sort data=a1;by ind year;run;
%macro test;
%do i=1 %to 2574;
proc means data=a1 noprint;
           var roa;by ind year;
                   where &i~=num;
output out=t1(drop=_freq_  _type_) ;run;
%end;
%mend;
%test;



二维码

扫码加我 拉你入群

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

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

关键词:ROA 平均值 同行业 RETAIN output 上市公司 平均值 行业

a.xls

1.56 MB

数据集

teqel 发表于 2014-11-30 10:22:58 |显示全部楼层 |坛友微信交流群
TA的数据在哪?
ind代表行业?

使用道具

mingfeng07 学生认证  发表于 2014-11-30 11:42:30 |显示全部楼层 |坛友微信交流群
你的数据集中有两个变量stkcd和Ind,这两个哪个是作为同一行业的标准不太清楚,假如以stkcd作为同一行业的判别变量,再加上year则可以采用sql过程:
  1. proc sql;
  2. create table a1 as select a.stkcd,a.year,a.roa,b.roa as roa1 from a,a as b
  3.                    where a.stkcd=b.stkcd and a.year=b.year and a.roa^=b.roa
  4.                    order by stkcd,year,a.roa;/*通过where语句来对roa进行分类匹配同时剔除了i公司本身*/
  5. quit;
复制代码
从你的数据集中我没有看到公司的账面总资产,所以接下来的计算没法进行了。
已有 1 人评分学术水平 热心指数 信用等级 收起 理由
BraveMadMan + 3 + 3 + 3 观点有启发

总评分: 学术水平 + 3  热心指数 + 3  信用等级 + 3   查看全部评分

使用道具

bobguy 发表于 2014-12-1 02:55:52 |显示全部楼层 |坛友微信交流群
In fact you should re-shape your data first, then using proc means once and only once is a more efficient way and no macro is needed.  An easy example is attached below.



data ind;
  do id=1 to 10;
    x=ranuni(123);
        output;
  end;
run;

data ind2;

do i=1 to nobs;

  set ind nobs=nobs point=i;
   do index=1 to nobs;
     if index ne i then  output;
   end;

end;

stop;
run;

proc means data=ind2 n mean std;
class index;
var x;
run;

使用道具

BraveMadMan 发表于 2014-12-1 09:50:35 |显示全部楼层 |坛友微信交流群
mingfeng07 发表于 2014-11-30 11:42
你的数据集中有两个变量stkcd和Ind,这两个哪个是作为同一行业的标准不太清楚,假如以stkcd作为同一行业的判 ...
正解



使用道具

jingju11 发表于 2014-12-1 23:05:47 |显示全部楼层 |坛友微信交流群
As indicated, you need Total Assets (TA) in the dataset. From the formula, you can use SAS/SQL function of remerging summary statistics back. Jingju

  1. proc sql;
  2. create table abc2 as
  3. select  ind,/*--------type of company*/
  4.         stckcd,/*stckcd + year:unique*/
  5.         year,
  6.         ta,
  7.         roa,
  8.         sum(ta)-ta                          as s_ta,
  9.         sum(roa*ta)-roa*ta                  as s_roa_ta,
  10.         calculated s_roa_ta/calculated s_ta as roa_new
  11. from  a
  12. group by  ind,
  13.           year
  14. order by 1, 2, 3
  15. ;
  16. quit;
复制代码

使用道具

teqel 发表于 2014-12-1 23:44:22 |显示全部楼层 |坛友微信交流群
jingju11 发表于 2014-12-1 23:05
As indicated, you need Total Assets (TA) in the dataset. From the formula, you can use SAS/SQL funct ...
这个没有把I公司剔除出去

使用道具

jingju11 发表于 2014-12-1 23:54:37 |显示全部楼层 |坛友微信交流群
teqel 发表于 2014-12-1 23:44
这个没有把I公司剔除出去
why? say:
stckcd year ind roa
1        1990 x   0.01
1        1991 x   0.02
...
sum(roa)-roa is to teese out the current roa in the year.
JingJu

使用道具

jingju11 发表于 2014-12-1 23:59:04 |显示全部楼层 |坛友微信交流群
if i understand correctly, the formula should be identical to
ROA_new_current =(sum(all TA*ROA) - current TA*ROA)/(sum(all TA) - current TA);

JingJu

使用道具

teqel 发表于 2014-12-2 00:15:26 |显示全部楼层 |坛友微信交流群
jingju11 发表于 2014-12-1 23:54
why? say:
stckcd year ind roa
1        1990 x   0.01
很有意思,比我原来设想的要好

使用道具

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

本版微信群
加好友,备注cda
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-3-29 15:19