楼主: lizhewenbei
707 1

[问答] 请教大家,这个程序应该怎么简化呢? [推广有奖]

  • 15关注
  • 5粉丝

副教授

36%

还不是VIP/贵宾

-

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

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
proc sort data=test5;by stkcd descending year;run;
data test6;set test5;by stkcd;
retain m n o p q;
if not (first.stkcd) then soe=coalesce(soe,m);
if not (first.stkcd) then central_soe=coalesce(central_soe,n);
if not (first.stkcd) then provincial_soe=coalesce(provincial_soe,o);
if not (first.stkcd) then city_below_soe=coalesce(city_below_soe,p);
if not (first.stkcd) then other_soe=coalesce(other_soe,q);

m=soe;
n=central_soe;
o=provincial_soe;
p=city_below_soe;
q=other_soe;

drop m n o p q;
run;


二维码

扫码加我 拉你入群

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

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

关键词:provincial central RETAIN ending stkcd

沙发
whymath 发表于 2020-8-10 22:10:37 |只看作者 |坛友微信交流群
显然,是对列一系列元素执行相同的程序。建议使用数组:
  1. data test6;
  2.         set test5;by stkcd;
  3.         retain m n o p q;

  4.         array _tmp_ m n o p q;
  5.         array _raw_ soe central_soe provincial_soe city_below_soe other_soe;
  6.         if not first.stkcd then do over _tmp_;
  7.                 _raw_ = coalesce(_raw_,_tmp_);
  8.         end;
  9.         do over _tmp_;
  10.                 _tmp_ = _raw_;
  11.         end;

  12.         drop m n o p q;
  13. run;
复制代码

使用道具

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

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

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

GMT+8, 2024-4-19 18:05