不知道对不对,是不是你的要求
data test2;
set test1 ;
c=lag(a);
b=5; **假设你变量b的第一个数据是5;
b=b*a/c;
run;作者: shiyiming 时间: 2006-7-19 17:48 标题: hi 呵呵,谢谢楼上的回复。可能不行。
不过我自己琢磨出来了,
写了一个宏程序,里面再利用call symput语句,搞定了。作者: shiyiming 时间: 2006-7-19 21:20 标题: RE: 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]作者: shiyiming 时间: 2006-7-20 09:37 标题: 千万次的说 第一万次告诉你们,LAG不是取上一条记录的值的函数.
它只是看起来像.
[code:84909]data test1;
input a b;
cards;
1 3
4 .
5 .
6 .
;
run;
data test2(drop=lagb laga);
set test1;
retain lagb laga;
if _N_^=1 then b=lagb*a/laga;
lagb=b;
laga=a;
run; [/code:84909]作者: shiyiming 时间: 2006-7-20 19:22 标题: to ahuige 那他是取什么值呀作者: shiyiming 时间: 2006-7-28 17:12 标题: to godensjj lag需要指定位置,就跟在后面。