|
|
5#

楼主 |
发表于 2008-4-11 10:59:55
|
只看该作者
Re: 请教:多个变量排序后first.variable引用的问题
上午在大家的建议下,看了帮助文件,逻辑还是有点混乱啊,
“How the DATA Step Identifies BY Groups”
1、How SAS Determines FIRST.VARIABLE and LAST.VARIABLE
When an observation is the first in a BY group, SAS sets the value of FIRST.variable to 1 for the variable whose value changed, as well as for all of the variables that follow in the BY statement. For all other observations in the BY group, the value of FIRST.variable is 0. Likewise, if the observation is the last in a BY group, SAS sets the value of LAST.variable to 1 for the variable whose value changes on the next observation, as well as for all of the variables that follow in the BY statement. For all other observations in the BY group, the value of LAST.variable is 0. [color=#FF0000:ihx9kj61]For the last observation in a data set, the value of all LAST.variable variables are set to 1.[/color:ihx9kj61],
同时这一页的帮助文件还有一句
2、Grouping Observations: Another Example
[color=#FF0000:ihx9kj61]The value of FIRST.variable can be affected by a change in a previous value, even if the current value of the variable remains the same. [/color:ihx9kj61],
问题:结合这句和前面的帮助文件,大体意思是说:first.variable以及last.variable不仅仅收到自身顺序的影响,同时还收到放在它前面的变量顺序的影响,但是具体是什么影响呢?请教一下大家,呵呵。
解决:是不是指在by后面的一系列变量中,前面的始终影响后面的?具体说,就是指前面的一个by变量(假若是a)的观测值改变了,放在它后面的by变量(假若是b),无论针对这一变量(b)的观测值是否改变,first.b和last.b都要随着first.a和last.a变化而做同样的变化?在此基础上,数据集的最后一个观测值的所有变量的last.variable都是1?
不知道我的理解是不是正确的 <!-- s:shock: --><img src="{SMILIES_PATH}/icon_eek.gif" alt=":shock:" title="Shocked" /><!-- s:shock: --> |
|