*! version 1.0 J.D. Raffo May 2016
program repisolatin
 version 12
 syntax varlist(string) [if] ///
   , [Generate(string) Tag(string)]

 // setup //////////////////////////////////////
 if ("`tag'"!="" & "`generate'"!="") {
  di "Invalid syntax. Generate and Tag cannot be selected at the same time."
  exit
  }
 // programs starts
 preserve
 tokenize `varlist'
 foreach curvar of var `varlist' {
  if ("`tag'"!="") {
   cap confirm variable `tag'
   if !_rc local generate `tag'
  }
  if ("`generate'"!=""){
   if ("`2'"=="") local repvarname `generate'
   else local repvarname `generate'`curvar'
   qui gen `repvarname'=`curvar' `if'
  }
  else local repvarname `curvar'
  qui {
	replace `repvarname'=subinstr(`repvarname',"&aacute;","a",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&Aacute;","A",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&abreve;","a",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&Abreve;","A",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&acirc;","a",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&Acirc;","A",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&aelig;","ae",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&AElig;","AE",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&agrave;","a",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&Agrave;","A",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&aogon;","a",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&Aogon;","A",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&aring;","a",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&Aring;","A",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&atilde;","a",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&Atilde;","A",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&auml;","a",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&Auml;","A",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&breve;"," ",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&cacute;","c",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&Cacute;","C",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&caron;"," ",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&ccaron;","c",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&Ccaron;","C",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&ccedil;","c",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&Ccedil;","C",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&dblac;"," ",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&dcaron;","d",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&Dcaron;","D",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&dot;"," ",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&dstrok;","d",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&Dstrok;","D",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&eacute;","e",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&Eacute;","E",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&ecaron;","e",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&Ecaron;","E",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&ecirc;","e",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&Ecirc;","E",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&egrave;","e",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&Egrave;","E",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&eogon;","e",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&Eogon;","E",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&eth;","d",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&ETH;","D",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&euml;","e",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&Euml;","E",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&iacute;","i",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&Iacute;","I",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&icirc;","i",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&Icirc;","I",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&igrave;","i",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&Igrave;","I",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&iuml;","i",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&Iuml;","I",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&lacute;","l",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&Lacute;","L",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&lcaron;","l",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&Lcaron;","L",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&lstrok;","l",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&Lstrok;","L",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&nacute;","n",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&Nacute;","N",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&ncaron;","n",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&Ncaron;","N",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&ntilde;","n",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&Ntilde;","N",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&oacute;","o",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&Oacute;","O",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&ocirc;","o",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&Ocirc;","O",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&odblac;","o",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&Odblac;","O",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&ogon;","o",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&ograve;","o",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&Ograve;","O",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&oslash;","o",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&Oslash;","O",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&otilde;","o",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&Otilde;","O",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&ouml;","o",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&Ouml;","O",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&racute;","r",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&Racute;","R",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&rcaron;","r",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&Rcaron;","R",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&sacute;","s",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&Sacute;","S",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&scaron;","s",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&Scaron;","S",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&scedil;","s",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&Scedil;","S",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&szlig;","ss",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&tcaron;","t",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&Tcaron;","T",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&tcedil;","t",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&Tcedil;","T",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&thorn;","th",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&THORN;","TH",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&uacute;","u",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&Uacute;","U",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&ucirc;","u",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&Ucirc;","U",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&udblac;","u",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&Udblac;","U",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&ugrave;","u",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&Ugrave;","U",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&uring;","u",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&Uring;","U",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&uuml;","u",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&Uuml;","U",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&yacute;","y",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&Yacute;","Y",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&yuml;","y",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&zacute;","z",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&Zacute;","Z",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&zcaron;","z",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&Zcaron;","Z",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&zdot;","z",.) `if'
	replace `repvarname'=subinstr(`repvarname',"&Zdot;","Z",.) `if'
  }
 }
 restore, not
end