Skip to content

Instantly share code, notes, and snippets.

@robinkraft
Created February 10, 2012 01:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robinkraft/1785225 to your computer and use it in GitHub Desktop.
Save robinkraft/1785225 to your computer and use it in GitHub Desktop.
Replacing monthly values in Stata
forvalues year = 2005/2011 {
forvalues month = 1/12 {
if `month' < 10 {
local mo_str = "0`month'"
}
else {
local mo_str = "`month'"
}
local yearmo = "`year'`mo_str'"
di "`yearmo'"
capture confirm variable prob`yearmo'
if !_rc {
replace prob`yearmo' = 103 if prob`yearmo' == 101
replace prob`yearmo' = 101 if prob`yearmo' == 111
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment