use forvalues stata
> local mcode 0
> local month jan feb mar apr
> foreach m of local month {
local mcode = `mcode' + 1
display "`mcode': `m'"
}
1: jan
2: feb
3: mar
4: apr
use forvalues stata
> local mcode 0
> local month jan feb mar apr
> foreach m of local month {
local mcode = `mcode' + 1
display "`mcode': `m'"
}
1: jan
2: feb
3: mar
4: apr
use forvalues stata
> forvalues i=1/12 {
generate warm`i'=1 if fmtemp`i' > fmtemp`i'[_n-1]
replace warm`i'=0 if fmtemp`i' <= fmtemp`i'[_n-1]
replace warm`i'=99 if year==2013
}
* see the results
> list year fmtemp1-fmtemp3 warm1-warm3, clean
year fmtemp1 fmtemp2 fmtemp3 warm1 warm2 warm3
1. 2013 39.2 37.4 41 99 99 99
2. 2014 30.2 37.4 41 0 0 0
3. 2015 35.6 30.2 44.6 1 0 1
use forvalues stata
* define a local macro called month
> local month jan feb mar apr
> display `"`month'"'
jan feb mar apr
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us