| Date: | Thu, 22 May 1997 09:37:47 -0800 |
| Reply-To: | Fran Kaplan <Frances_Kaplan@PREMIER-RESEARCH.COM> |
| Sender: | "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU> |
| From: | Fran Kaplan <Frances_Kaplan@PREMIER-RESEARCH.COM> |
| Subject: | FWD> help in modifying |
FWD> help in modifying obs
To <SAS-L@VM.MARIST.EDU>
>I have two num. variables ("type" and "key"). Type takes
values (1, 2, or 3)
>while "key" takes values (7, 8, 9, 2 ...). What I want to
do is:
>If for observation i, key=3, then for the immediately
preceding observation
>(i-1), I want the key value to become the value of key(i).
To obtain the preceding value of a variable you would want
to use the LAG function. I would suggest taking the lag of
the variable regardless of the value of type. Using IF
subsetting tends to cause problems when using lag since what
happens is you get the previous value of KEY that has a TYPE
= 3. So, take the lag of key (lagkey=lag(key)), THEN only
read the observations that have a value of 3 for type. Hope
this helps!
Fran
|