SAS中文论坛

 找回密码
 立即注册

扫一扫,访问微社区

查看: 668|回复: 3
打印 上一主题 下一主题

利用一列row1里数据求下面row的数 --- 也想求一名sas 高手, 以后可以随时回到出现的一些问题。合理付费!

[复制链接]

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
楼主
 楼主| 发表于 2009-5-25 23:12:25 | 只看该作者

利用一列row1里数据求下面row的数 --- 也想求一名sas 高手, 以后可以随时回到出现的一些问题。合理付费!

请高手指导! 也想求一名sas 高手, 以后可以随时回到出现的一些问题。合理付费!


i have a time series data file that has about 3.5million observations. to give an example, the original data looks like this:

Column1:  Column2:  Column3:
x              c1            t1
y              c2            t2
.               c3            t3
.               c4            t4

in Column1, i have values X, Y, respectively in the first two rows. the rest of the rows in Column1 is empty. i want to use X and Y (values in the first two rows of Column1) to generate value for all the other rows in Column1, using the formula Column2 * (Column3 - lag2(column1)) + lag2(column1)

for example, to get the value for Column1, row 3, we want to take the lag2 value of the row, which is x, and do C3 *(t3-x)+x.   for Column1, row 4, it should be C4 *(t4-y)+y

we want to finished data to be like this

Column1:
x
y
C3 *(t3-x)+x
C4 *(t4-y)+y
C3 *(t3-(C3 *(t3-x)+x))+(C3 *(t3-x)+x)
C4 *(t4-(C4 *(t4-y)+y))+(C4 *(t4-y)+y)
.
.
.

i have tried doing something like:

if row>2 thencolumn1 = lag2(Column1)

but it doesn't work.

Can you figure something out?  Thanks!
回复 支持 反对

使用道具 举报

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
沙发
 楼主| 发表于 2009-5-25 23:48:56 | 只看该作者

Re: 利用一列row1里数据求下面row的数 --- 也想求一名sas 高手, 以后可以随时回到出现的一些问题。合理付费!

我也遇到过这样的问题,跪求达人指教。
回复 支持 反对

使用道具 举报

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
板凳
 楼主| 发表于 2009-5-26 10:05:41 | 只看该作者

Re: 利用一列row1里数据求下面row的数 --- 也想求一名sas 高手, 以后可以随时回到出现的一些问题。合理付费!

你试着去添加一个column,然后用这个column去记录行数。比如讲,这个column的名字叫obs。你就可以用:
if obs>2 then......
回复 支持 反对

使用道具 举报

0

主题

0

帖子

2

积分

新手上路

Rank: 1

积分
2
地板
发表于 2009-5-26 11:54:52 | 只看该作者

Re: 利用一列row1里数据求下面row的数 --- 也想求一名sas 高手, 以后可以随时回到出现的一些问题。合理付费!

You may try the below code.
[code:ks1nnmin]data temp;
input y c t;
cards;
1 2 3
2 3 4
. 5 6
. 7 8
. 9 10
. 100 10
;
run;

data v;
retain la1 la2;
set temp;
x=lag(y);
if _n_=2  then do;
la2=x;
la1=y;
end;
if _n_>=3   then do;
y=c*(t-la2)+la2;
la2=la1;
la1=y;
end;
keep y c t;
run; [/code:ks1nnmin]
回复 支持 反对

使用道具 举报

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

本版积分规则

QQ|小黑屋|手机版|Archiver|SAS中文论坛  

GMT+8, 2026-2-5 17:54 , Processed in 0.067233 second(s), 20 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表