sweetsciencereigns
sweetsciencereigns

Reputation: 31

SPSS: Count variables till one variable has a value over 0

I Have a SPSS data set about Drinking behaviour. There are 90 Variables for 90 Days. I want to figure out how many days it took for each participant to consume the first drink to calculate the number of days to first drink.

So I think about something like "count variables till one of the variables has a value above 0."

Do you see any possibility to perform such a task in SPSS?

I would be very happy to get some help. Thanks a lot!

Upvotes: 2

Views: 119

Answers (1)

horace_vr
horace_vr

Reputation: 3176

COMPUTE counter=0.
COMPUTE stopper=0.

DO REPEAT X= [your 90 variables here].
if X<>0 and stopper=0 counter=counter+1.
if X=0 stopper=1.
END REPEAT.
EXECUTE.

Upvotes: 3

Related Questions