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
Reshaping Data, Wide format from long Hello everyone, I'm having trouble formatting my data. I have a dataset that looks like this: Cou…
How to select categorical variable in Hoteck method to impute missing dataHello Everyone I am trying to address the missing values of four variables (price) in my research an…
The new AUTOArima Mata class: you are free to use it if you want auto-ARIMA in your commandThanks to Kit Baum's adding the arimaauto command to the SSC, the class is publicly available after …
Installing package not on SSCI am trying to install the package 'meta'. I have commands in a file I am trying to use where the co…
Auto-ARIMA is now available in Stata! The new arimaauto and xtarimau commandsThanks to Kit Baum's relentless work on uploading new packages into the SSC, Stata now has auto-ARIM…
Subscribe to:
Post Comments (Atom)
0 Response to Creating Loop
Post a Comment