thanks for that

, but it didn't really work. It gives a "1" in the record where event001=1 and the next one.

It should be in all the next lines with the same PATCOD (not necessarily where Event001=1)

I'm not familiar with the command LAG(variable), I should educate myself...Is there a clear explanation available for this on the net?

What I've done in the mean time is very complex and prone to mistakes (see below) . Can you see an obvious mistake?

*restructurate.

SORT CASES BY PATCOD Birthdate .

CASESTOVARS

/ID=PATCOD Birthdate

/GROUPBY=VARIABLE.

*than computed a new variabel

COMPUTE PREV0adm1=0.

compute prev1adm2=EVENT001.1.

COMPUTE PREV2adm3=EVENT001.1 + EVENT001.2.

COMPUTE PREV3adm4=EVENT001.1 + EVENT001.2 +EVENT001.3.

etc

*than restructurated it back

VARSTOCASES

/MAKE PREVV FROM PREV0adm1 prev1adm2 PREV2adm3 PREV3adm4

/INDEX=Index1(4)

/KEEP=PATCOD

/NULL=DROP

/COUNT=casenr.

RECODE PREVV (0=0) (1 thru Highest=1) INTO Pr_event.

EXECUTE.