Hi

I have codes for a few states - {3,4,5,6,1}
and years -{ 2007,2008}
and indexes- {3,5,2,4,5,2,4,5,7,9}.

The indexes are in a particular order. The first five are for states with codes {3,4,5,6,1} in the same order for year 2007 and last five are again for the same states in the same order in year 2008.

There is a variable inflation which has to be adjusted using these indexes.

For example,

replace inflation = inflation * 3 if state == 3 and year == 2007.


How do i do it for all states and years using a loop.

Started writing it.


foreach y in 2007 2008 {
foreach s in 3 4 5 6 1{
replace inflation = inflation*-------------------- if year ==`y' and state ==`s'
}
}


I am not able to understand how to access the indexes inside the loop. Will a local variable have to be created ?