Thank you for the above response 🙂 However, I would expect it to look like follows (I have also added how it would look like the for EVENT mentioned at the beginning of this thread): ID NEWID EVENT AEID LINKID
------------------------------------------------------------------------
101 7 Rash_maculo-papular 5 5
101 12 Rash_maculo-papular 7 5
101 15 Rash_maculo-papular 12 5
101 . Rash_maculo-papular 15 5
101 19 Rash_maculo-papular 18 18
101 . Rash_maculo-papular 19 18 102 . Dyspnoea 1 2 102 1 Dyspnoea 2 2 So for ID 101 when NEWID = 7 and EVENT = Rash_maculo-papular this is classed as the first occurence of the EVENT within the linked EVENTS - so LINKID is populated with 5 already. And then for ID 101 when NEWID = 19 and EVENT = Rash_maculo-papular this is classed as the first occurence of the EVENT within the linked EVENTS - so LINKID is populated with 18 already. So then when NEWID = AEID I'd like LINKID to be populated with the LINKID from the first occurence (as shown above) This was done fine in the code I was using, when using a retain function. However, the second example I have given causes problems as I cannot use a retain function on that. For ID 102 when NEWID = 1 and EVENT = DYSPNOEA this is classed as the first occurence of the EVENT, so LINKID is populated with 2 already for that observation. So I'm wanting the record above it, where the NEWID = AEID to be populated with the LINKID from the first occurence (which would be 2). So I'm hopefully looking for a solution with the outcome of the table above. I really appreciate the help so far!, it's just a really awkward one to try to explain, so hoping the above can clear it up abit 🙂
... View more