a*****b 发帖数: 2789 | 1 我有N多个observation,已经读入为sas data。如下
variable1
11
22
33
44
。
。
。
12
13
14
。
。
。
我现在想比较variable1的相邻observation之间的关系。比如obs3
继续向下比较(实际情况很复杂)。想用数组来做。不知道可不可以把variable1下面的
所有数据定义成数字型数组,比如variable1(i)代表第i个数,然后我在data里面做
循环?array好像是循环变量的,对变量值不好操作,而且我又不方便把variable1转成
n个新变量。
请问应该如何定义?需要用到的proc或者function是什么?谢谢 |
p********a 发帖数: 5352 | 2 看起来有点象股票里的BID,哈哈。你应该还有个时间变量啊,提供一点TIP
data tc;
set tc;
retain I1;
if pt>lag(pt) then I1=1; else if pt
run; |
o****o 发帖数: 8077 | 3 no need to use array, just take the whole data file as a big array, and use
random access method: point=i; you can control i freely
【在 a*****b 的大作中提到】 : 我有N多个observation,已经读入为sas data。如下 : variable1 : 11 : 22 : 33 : 44 : 。 : 。 : 。 : 12
|
a*****b 发帖数: 2789 | 4
use
~~~~~~~~how to do that, can you say that in more
detail?
【在 o****o 的大作中提到】 : no need to use array, just take the whole data file as a big array, and use : random access method: point=i; you can control i freely
|
a*****b 发帖数: 2789 | 5 yes, lag may work. But i also need forward lag here.do you know what's the
function or option for FORWARD LAG?
【在 p********a 的大作中提到】 : 看起来有点象股票里的BID,哈哈。你应该还有个时间变量啊,提供一点TIP : data tc; : set tc; : retain I1; : if pt>lag(pt) then I1=1; else if pt: run;
|
o****o 发帖数: 8077 | 6 I need to know more details on the operations you want to do
【在 a*****b 的大作中提到】 : yes, lag may work. But i also need forward lag here.do you know what's the : function or option for FORWARD LAG?
|
G**S 发帖数: 1108 | 7 agree
【在 o****o 的大作中提到】 : I need to know more details on the operations you want to do
|
g**r 发帖数: 425 | 8 One way is to read the dataset to IML, then you can treat your variable as a
vector and var[i] will just be your element.
【在 a*****b 的大作中提到】 : 我有N多个observation,已经读入为sas data。如下 : variable1 : 11 : 22 : 33 : 44 : 。 : 。 : 。 : 12
|
a*****b 发帖数: 2789 | 9 哦,我试试。好像很不错的样子,不过要新学IML的东西,捣鼓一下先
a
【在 g**r 的大作中提到】 : One way is to read the dataset to IML, then you can treat your variable as a : vector and var[i] will just be your element.
|