Dear all,
I am working with a dataset which has 24 float variables named temp1-temp24 (among many other variables). The variables temp1-temp24 have values of 0, 1, 2 or 3 and there is no pattern to their order, aside from that a value of 1 will always have a value of 2 or 3 as one of the subsequent variables.
I would like help writing code that would allow me to create a new variable (newvar) that contains the value of the first occurrence of 2 or 3 that follows a 1 please (example below)? I would be grateful for all help and advice given.
Epikey temp1 temp2 temp3 temp4 temp5 temp6 temp7 temp8 temp9 temp10 temp11 temp12 temp13 temp14 temp15 temp16 temp17 temp18 temp19 temp20 temp21 temp22 temp23 temp24 Newvar
1 0 1 2 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2
2 3 0 0 1 0 0 2 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 2
3 0 1 0 3 0 2 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3
I am working with a dataset which has 24 float variables named temp1-temp24 (among many other variables). The variables temp1-temp24 have values of 0, 1, 2 or 3 and there is no pattern to their order, aside from that a value of 1 will always have a value of 2 or 3 as one of the subsequent variables.
I would like help writing code that would allow me to create a new variable (newvar) that contains the value of the first occurrence of 2 or 3 that follows a 1 please (example below)? I would be grateful for all help and advice given.
Epikey temp1 temp2 temp3 temp4 temp5 temp6 temp7 temp8 temp9 temp10 temp11 temp12 temp13 temp14 temp15 temp16 temp17 temp18 temp19 temp20 temp21 temp22 temp23 temp24 Newvar
1 0 1 2 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2
2 3 0 0 1 0 0 2 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 2
3 0 1 0 3 0 2 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3
Comment