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 ?
Related Posts with Creating Loop
Test for math \[ \frac{2}{3}+ \mathbf{\pi} \] \[ y = \beta*x + \gamma *x * \varepsilon \] …
Adding Independent Variables in RegressionHi there! I am new to Stata and am eager to learn. I am currently doing an OLS regression on a cros…
create dummy showing 36&60 months after event dateDear statalists, I am trying to create a variable to flag the 36th and 60th months after each event…
Zero-inflated models for binary variablesDear all, I am running multilevel regressions on a binary dependent variable characterised by a majo…
Estimating TFP by industry using prodestDear Stata users, I estimate TFP using prodest command (ssc install prodest) and have one question …
Subscribe to:
Post Comments (Atom)
0 Response to Creating Loop
Post a Comment