看起来是一个很简单的链式计算,在excel中很容易就可实现了,可俺在sas中怎么也没写出来,具体如下:
两个数值型变量a和b,100条记录,变量a已有值,变量b只有第一条记录有值,
后面均为空值,现通过下面关系计算剩余的b变量的值,
b=lag(b)*a/lag(a), 我写了如下程序:
data test2;
set test1;
if _n_ ^=1 then
b=lag(b)*a/lag(a;
output;
run;
Make sure the syntax is correct in your testing codes. But there was a ')' missing at the end in your sample code.
[code:8ced6]
if _n_ ^=1 then
b=lag(b)*a/lag(a;
[/code:8ced6]