由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - SAS lag function question
相关主题
help for SAS codesas 9.3 install questions
sas question, please help!Unexpected statistical analysis results in Cox regression
SAS statement显示是红色 但是依然可以运作 会有什么问题吗大家习惯round(2.5)=3还是2?
a question about visit window calculation匹大归来~~
Put an order variable in a smart way in SAS关于预测模型方面的面试
help for sas code请教一个sas问题
mixed model questionhelp:data manipulation
什么时候r里兴用=赋值的Data Manipulation(Help)
相关话题的讨论汇总
话题: previst话题: lag话题: visit话题: last2话题: 10
进入Statistics版参与讨论
1 (共1页)
u*****b
发帖数: 14
1
the purpose is to get the previous visit number of a same id
the following lines give me an unexpected result. Anyone knows the reason?
thanks
data aaa;
input id $ visit;
cards;
10 1
10 2
10 4
2 1
2 2
;
run;
data last2;
set aaa;
if (id = lag(id)) then previst = lag(visit);
else previst=0;
run;
'last2' looks like this
id visit previst
10 1 0
10 2 .
10 4 2
2 1 0
2 2 4
o******6
发帖数: 538
2
data last2;
set aaa;
by id;
previst = lag(visit);
if first.id then previst=0;
run;

【在 u*****b 的大作中提到】
: the purpose is to get the previous visit number of a same id
: the following lines give me an unexpected result. Anyone knows the reason?
: thanks
: data aaa;
: input id $ visit;
: cards;
: 10 1
: 10 2
: 10 4
: 2 1

o******6
发帖数: 538
3
BTW,remember that the value returned by the lag function is the value of the
argument the last time the function was executed.

【在 u*****b 的大作中提到】
: the purpose is to get the previous visit number of a same id
: the following lines give me an unexpected result. Anyone knows the reason?
: thanks
: data aaa;
: input id $ visit;
: cards;
: 10 1
: 10 2
: 10 4
: 2 1

u*****b
发帖数: 14
4
o. i see. thanks

the

【在 o******6 的大作中提到】
: BTW,remember that the value returned by the lag function is the value of the
: argument the last time the function was executed.

o******6
发帖数: 538
5
不客气,我也在学习中,以后多交流。

【在 u*****b 的大作中提到】
: o. i see. thanks
:
: the

1 (共1页)
进入Statistics版参与讨论
相关主题
Data Manipulation(Help)Put an order variable in a smart way in SAS
请教一个PROC MIXED做REPEATED MEASUREMENT问题help for sas code
a simple Bayesian questionmixed model question
弱问一个data clean的问题,求各位指点。什么时候r里兴用=赋值的
help for SAS codesas 9.3 install questions
sas question, please help!Unexpected statistical analysis results in Cox regression
SAS statement显示是红色 但是依然可以运作 会有什么问题吗大家习惯round(2.5)=3还是2?
a question about visit window calculation匹大归来~~
相关话题的讨论汇总
话题: previst话题: lag话题: visit话题: last2话题: 10