Help with Loops

Moderators: statman, Analyst Techy, andris, Fierce, GerineL, Smash

EinLynn
Posts: 1
Joined: Thu May 16, 2013 6:11 pm

Help with Loops

Postby EinLynn » Thu May 16, 2013 6:20 pm

I have a series of 12 variables, Address_pk.01 to Address_pk.12.

I want to create 11 new variables that compare one address to the next.

So I want:
Moved01 to = 1 if Address_pk.01 <> Address_pk.02.
Moved02 = 1 if Address_pk.02 <> Address_pk.03.
Moved03 = 1 if Address_pk.03 <> Address_pk.04, etc.

I came up with this, but it's not producing the correct numbers and I'm not sure what I'm doing wrong. When I do a hand-comparison of Address_pk.01 to Address_pk.02, I come up with 488 cases where Moved01 = 1. But the syntax below only produces n=469. What am I doing wrong?

* Check if address code is different from the previous year.
VECTOR vAddr = address_pk.01 to address_pk.12.
VECTOR vMove(11).
LOOP #I = 1 to 12.
LOOP #J = (#i + 1) to 12.
IF vAddr(#i) <> vAddr(#j) vMove(#i) = 1.
IF vAddr(#i) = vAddr(#j) vMove(#i) = 0.
END LOOP.
END LOOP.
EXECUTE.

Who is online

Users browsing this forum: No registered users and 1 guest

cron