Loops in SPSS - creating new variable based on multiple loops??

Verap93

New Member
Hi,

I am looking for help! Maybe someone here knows the answer?

I want to make a new variable (in SPSS) Date_flare_FU (Date of a disease flare during follow up). This variable will be based on 12 follow up visits (Date_T1 tm Date_T12 -> date), during which disease activity is assessed (DiseaseActivity_T1 tm _T12 -> disease is active? = yes/no). If the disease is active during FU (e.g. DiseaseActivity_T3 = 1) the date of that FU-moment (Date_T3) should be copied to the new variable (Date_flare_FU). I tried to make a loop, but it isn't working. Some ideas how to fix and to shorten it?

COMPUTE Date_flare_FU = 0.
FORMATS Date_flare_FU (DATE11).
VECTOR A = Date_T1 TO Date_T12.
LOOP #v = 1 TO 12.
DO IF (DiseaseActivity_T1= 1 OR DiseaseActivity_T2 =1 OR DiseaseActivity_T3 =-9 OR .... TO DiseaseActivity_T12 =-9).
COMPUTE Date_flare_FU = A(#v).
ELSE IF (DiseaseActivity_T1= -9 OR DiseaseActivity_T2 =-9 OR DiseaseActivity_T3 =-9 OR .... TO DiseaseActivity_T12 = -9 OR
DiseaseActivity_T1= 2 OR DiseaseActivity_T2 =2 OR DiseaseActivity_T3 =2 OR .... TO DiseaseActivity_T12 = 2 OR
DiseaseActivity_T1= 0 OR DiseaseActivity_T2 =0 OR DiseaseActivity_T3 =0 OR .... TO DiseaseActivity_T12 = 0).
COMPUTE Date_flare_FU=-9.
ELSE.
RECODE Date_flare_FU (ELSE=COPY).
END IF.
END loop.
EXECUTE.

Greetings, Vera

Verap93

New Member
Found a solution:

COMPUTE Date_flare_FU = 0.
FORMATS Date_flare_FU (DATE11).
VECTOR A = Disease_activity_T1 TO Disease_activity_T12.
VECTOR B = Date_T1 TO Date_T12.
LOOP #v = 1 TO 12.
DO IF (A(#v)=1).
COMPUTE Date_flare_FU = B(#v).
END IF.
END loop IF (A(#v)=1).
EXECUTE.