请选择 进入手机版 | 继续访问电脑版
楼主: Lakeyi
2417 13

[有偿编程] 筛选需要的数值 [推广有奖]

Lakeyi 发表于 2014-8-1 11:27:50 |显示全部楼层 |坛友微信交流群
freerunning_sky 发表于 2014-8-1 11:02
搞好了!有个问题就是 有的是从2006年开始的 有的是2001年  能不能都2001年开始

使用道具

freerunning_sky 在职认证  发表于 2014-8-1 11:33:01 |显示全部楼层 |坛友微信交流群
Lakeyi 发表于 2014-8-1 11:27
搞好了!有个问题就是 有的是从2006年开始的 有的是2001年  能不能都2001年开始
2001年的取什么值?还有最终都需要到2012年么?

使用道具

freerunning_sky 在职认证  发表于 2014-8-1 11:33:37 |显示全部楼层 |坛友微信交流群
Lakeyi 发表于 2014-8-1 11:25
报错咧=。=
我跑的很正常,不知道你怎么会报错

使用道具

Lakeyi 发表于 2014-8-1 09:41
大哥还能不能补充年份呢 没有的年份是默认上一年的
如要对缺失年份数据,用上一年数据进行补缺,则(你的文件名改为abcd,结果看test):
data tmp1;
  set dmc2.abcd;
  yr=year(shrchgdt);
run;

proc sort data = tmp1;
by stkcd shrchgdt;
run;

data tmp2;
  set tmp1;
  by stkcd yr;
  if last.yr then output;
run;

data tmp3(keep= stkcd2 yr2  rename=(stkcd2=stkcd yr2=yr));
set tmp2;
by stkcd;
retain yr2 stkcd2;
if  first.stkcd then do;yr2=yr;stkcd2=stkcd; output;end;
else if not(first.stkcd) and yr=yr2 then do;output;yr2=yr2+1;end;
else if not(first.stkcd) and yr>yr2 then do until (yr=yr2);
                yr2=yr2+1;output;
                end;
run;

data tmp4;
merge tmp3 tmp2;
by stkcd yr;
run;

data test(drop=a);
set tmp4;
by stkcd;
retain a;
if first.stkcd then a=NSHRTTL;
else if not(first.stkcd) and NSHRTTL ^=. then a=NSHRTTL;
else if not(first.stkcd) and NSHRTTL =. then NSHRTTL=a;
run;

proc datasets;
delete tmp1-tmp4;
run;

使用道具

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

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

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

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