Date: Fri, 15 Oct 1999 10:59:58 -0400
Reply-To: "Stein, Christopher D" <christopher_d_stein@GROTON.PFIZER.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Stein, Christopher D" <christopher_d_stein@GROTON.PFIZER.COM>
Subject: Re: What's wrong with the lag function?
Content-Type: text/plain; charset="iso-8859-1"
Not a specific answer to your question, but..... In my experience, problems
arise when the lag function is applied within a conditional expression. The
best best is to assign the lagged value unconditionally and use it
conditionally.
Chris
___________________________________________
Chris Stein
SAS and Statistical Software Support Services (S5)
CBSU Customer Center
Pfizer Central Research
Groton, CT 06370
(860) 441-6825
christopher_d_stein@groton.pfizer.com
___________________________________________
-----Original Message-----
From: Huang, Ya [mailto:Y.Huang@ORGANONINC.COM]
Sent: Friday, October 15, 1999 10:27 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: What's wrong with the lag function?
Hello All,
This question seems to have been asked by somebody long time ago, I don't
remember the answer, so forgive me to ask it again.
Can somebody explain to me why I have to use a intermediate variable
to keep the lag value and then I can use it to assign to other variable?
DATA XX;
INPUT A B C;
CARDS;
1 2 1
3 4 1
5 6 0
7 8 1
;
data yy; set xx;
if c=0 then a=lag(b); /** not working ***/
PROC PRINT;
data zz; set xx;
d=lag(b);
if c=0 then a=d; /** this way works **/
proc print;
run;
Syntaxly no error in both of the data steps, logically I really don't see
the difference between these two data steps, so what is really going on?
Thanks
Ya Huang