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
difference between logit and xtlogithi What is the difference between logit and xtlogit codes in Stata? In terms of assumptions applies…
Two stage least square - instrumental variable -use industry medianDear Listers, I read a research paper using industry median as instrument to deal with endogeneity …
Expanding window through existing mata codeDear Statalist, I have some working code, but I would like to alter is so the result is an expandin…
Putexcel issue Dear Statalister, I have a issue of the following code. When I run the code it works for the first …
graph malfunctionHi folks, I am trying to create a fractional polynomial over a scatter plot but the curve doesn't ap…
Subscribe to:
Post Comments (Atom)
0 Response to Creating Loop
Post a Comment