H***y 发帖数: 340 | 1 为什么不能用first.和last.呢?
log
NOTE: 变量 first.ticker 未初始化。
NOTE: 变量 last.ticker 未初始化。
NOTE: 从数据集 STARTUP.REGTEST 读取了 26 个观测。
NOTE: 数据集 STARTUP.REGBEGIN 有 0 个观测和 6 个变量。
NOTE: 数据集 STARTUP.REGEND 有 0 个观测和 6 个变量。
code
data startup.regbegin startup.regend;
set startup.regtest;
if first.ticker
then do;
begindate=date;
format begindate date9.;
output startup.regbegin;
end;
if last.ticker
then do;
|
d*******1 发帖数: 854 | 2 after set startup.regtest;
you need to add the following:
by ticker;
【在 H***y 的大作中提到】 : 为什么不能用first.和last.呢? : log : NOTE: 变量 first.ticker 未初始化。 : NOTE: 变量 last.ticker 未初始化。 : NOTE: 从数据集 STARTUP.REGTEST 读取了 26 个观测。 : NOTE: 数据集 STARTUP.REGBEGIN 有 0 个观测和 6 个变量。 : NOTE: 数据集 STARTUP.REGEND 有 0 个观测和 6 个变量。 : code : data startup.regbegin startup.regend; : set startup.regtest;
|
H***y 发帖数: 340 | 3 got it. thanks.
but, in fact, the data was sorted by ticker,
why "by" again? |
d*******1 发帖数: 854 | 4 you dataset startup.regtest has been pre-sorted. The ordering information is
embeded in the dataset. when you do
data startup.regtest;
set startup.regtest;
you are actually recreating the dataset startup.regtest, you would lose the
ordering information during this recreation process if you do not tell SAS
to keep the ordering information by using by statement again.
【在 H***y 的大作中提到】 : got it. thanks. : but, in fact, the data was sorted by ticker, : why "by" again?
|
H***y 发帖数: 340 | 5 thanks a lot
very clear
is
the
【在 d*******1 的大作中提到】 : you dataset startup.regtest has been pre-sorted. The ordering information is : embeded in the dataset. when you do : data startup.regtest; : set startup.regtest; : you are actually recreating the dataset startup.regtest, you would lose the : ordering information during this recreation process if you do not tell SAS : to keep the ordering information by using by statement again.
|