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
¿Como mantener la escala x: 2007 - 2018 y graficar solo una barra 2017?* Example generated by -dataex-. To install: ssc install dataex clear input float(año pc pc_rural pc…
Rolling regression GARCH volatility predictionHello Statalisters, I have been attempting to run a rolling GARCH model that predicts variance with…
Panel Data Average Line GraphsHi everyone, I am using panel data and am trying to graph CEO compensation over a specific time peri…
How to generate a price index using the output of a regression (real estate)?Hi all, I would like to generate a price index to determine price changes between house prices in t…
Sensitivity analysis for missing valueDear statalist, I'm running a logistic regression and there are two independent variables with miss…
Subscribe to:
Post Comments (Atom)
0 Response to Creating Loop
Post a Comment