楼主: naivearies
11907 12

如何实现LOCF [推广有奖]

11
ch03en12tong 发表于 2015-7-3 15:40:57
if ^missing(a11) and missing(a12) then a12=a11;
if ^missing(a12) and missing(a13) then a13=a12;  

12
异常值 发表于 2020-8-31 10:13:38
data a;
set a;
retain b1 b2 b3;
if ^missing(a011) then b1=a011;
if ^missing(a021) then b2=a021;
if ^missing(a031) then b3=a031;
run;

13
涂涂2020 在职认证  发表于 2020-9-21 11:50:12
LOCF中文名称末次观测转结法,即若有数据缺失,则用该次观测前最后一次有效观测的数据对该数据进行填补(也可进行其他补充规定)。我一般是用向上填补过程实现的,
proc sort;by xx xx xx ;run;
data b;set a;
do i=1 to n;
l_x=lag(x);
  l_y=lag(y);
  if x=. and x=l_x then y=l_y;
end;
drop l_x l_y ;
run;

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

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-29 08:13