From: Tom Smith on
Sorry Stat changed it's mind. So I will need help on the following.

I have a following dataset with variables -Problem,subject,
cycle, dchange .


Problem subject cycle dchange
------ ------- ----- ----
pain 1001 1 0
1001 2 0
1001 3 0
1001 4 1
1002 1 0
pain 1002 2 0
1002 3 1
1002 4 0
pain 1003 1 0
1003 2 1
1003 3 0

I need a dataset as below: if the variable "Problem" has a
value "pain" and the value of variable dchange of next
record is equal to 1 ( previous record means -in which
record the variable 'problem" has a value 'pain") then
need all rest of the records for that pateint will
have the value= 1 for the new variable "flag" otherwise
flag will have the value = 0.




Problem subject cycle dchange flag
------ ------- ----- ---- -----
pain 1001 1 0 0
1001 2 0 0
1001 3 0 0
1001 4 1 0
1002 1 0 0
pain 1002 2 0 0
1002 3 1 1
1002 4 0 1
pain 1003 1 0
1003 2 1 1
1003 3 0 1



Thanks you so much from bottom of my heart.