SAS中文论坛

标题: 求教个填充数字的方法 [打印本页]

作者: shiyiming    时间: 2009-12-29 12:35
标题: 求教个填充数字的方法
var   value   
a       1
a       .
a       .
a       6
b       .
b       3
b       .
c       .
c       2  
c       .

想把得到下面的形式,怎么才可以每一个变量VAR的内部填充呢?

a       1
a       1
a       1
a       6
b       .
b       3
b       3
c       .
c       2  
c       2
作者: shiyiming    时间: 2009-12-29 22:35
标题: Re: 求教个填充数字的方法
[code:ygs62kio]data b;
        set a;
        by var;
        retain _value;
        if first.var then _value = value; *(Re-)initialize the retained value;
        if nmiss(value) then value = _value; *replace only missing by the afore-record;
        _value = value; *renew the value ;
        drop _value;
run;[/code:ygs62kio]




欢迎光临 SAS中文论坛 (https://mysas.net/forum/) Powered by Discuz! X3.2