computing new variable again

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

computing new variable again

Jean Hanson


I received some  great help yesterday with the following syntax

 

vector v=OCC_P to ILIUM_P.

compute UIV_P=0.

loop #i=1 to 29.

do if v(#i)=1.

compute UIV_P=#i.

BREAK.

end if.

end loop.

 

But now I want to do the reverse and calculate a variable starting from the bottom of the vector. I tried the following, which did not work.

 

vector v= OCC_P to ILIUM_P.

compute LIV_P=0.

loop #i=29 to 1.

do if v(#i)=1.

compute LIV_P=#i.

BREAK.

end if.

end loop.

 

In advance thanks for the help.

 

Jean Hanson

Reply | Threaded
Open this post in threaded view
|

Re: computing new variable again

Gyorgy Bea
Hi Jean,

Try this:

vector v= OCC_P to ILIUM_P.

compute LIV_P=0.

loop #i=29 to 1 BY -1.

do if v(#i)=1.

compute LIV_P=#i.

BREAK.

end if.

end loop.


Best regards,
Beata



From: Jean Hanson <[hidden email]>
To: [hidden email]
Sent: Tuesday, April 7, 2009 11:36:57 PM
Subject: computing new variable again


I received some  great help yesterday with the following syntax

 

vector v=OCC_P to ILIUM_P.

compute UIV_P=0.

loop #i=1 to 29.

do if v(#i)=1.

compute UIV_P=#i.

BREAK.

end if.

end loop.

 

But now I want to do the reverse and calculate a variable starting from the bottom of the vector. I tried the following, which did not work.

 

vector v= OCC_P to ILIUM_P.

compute LIV_P=0.

loop #i=29 to 1.

do if v(#i)=1.

compute LIV_P=#i.

BREAK.

end if.

end loop.

 

In advance thanks for the help.

 

Jean Hanson