program define bailey version 2.1 if "%_*"=="" { di in red "invalid syntax -- see help bailey" exit 198 } mac def _options "Dead(string) MAXiter(string) REscale Autofix(string) RHOmax(string) LAMbda(string) Interva(string) FXAlpha(string) FXGamma(string) FXDelta(string) SVAlpha(string) SVGamma(string) SVDelta(string) *" mac def _varlist "req ex" mac def _if "opt" mac def _in "opt" mac def _exp "opt" parse "%_*" parse "%_varlist", parse(" ") gen float _wt = 1 %_if %_in if ("%_exp"!="") { replace _wt %_exp %_if %_in} if ("%_maxiter"!="") { mac def _options "%_options maxiter=%_maxiter" } if ("%_autofix"!="") { mac def _options "%_options autofix=%_autofix" } if ("%_rhomax"!="") { mac def _options "%_options rhomax=%_rhomax" } if ("%_lambda"!="") { mac def _options "%_options lambda=%_lambda" } if ("%_dead"=="") { gen byte _dead=1 mac def _dead "_dead" } if ("%_interva"=="") { mac def _interva = 1 } cap confirm var interva if (_rc) { gen byte _interva = %_interva mac def _interva "_interva" } quietly save _bailey, replace capture { !echo options altquote weight=_wt %_options ; > _parmfil !echo stata #_bailey.dta#; >> _parmfil !echo depend %_1 %_dead %_interva ; >> _parmfil mac shift * What if its too long? !echo logfile #_stata.log#; >> _parmfil !echo varlist %_*; >> _parmfil !echo output #_bailey.mta#; >> _parmfil !echo sv_alpha %_svalpha ; >> _parmfil !echo sv_gamma %_svgamma ; >> _parmfil !echo sv_delta %_svdelta ; >> _parmfil !echo fx_alpha %_fxalpha ; >> _parmfil !echo fx_gamma %_fxgamma ; >> _parmfil !echo fx_delta %_fxdelta ; >> _parmfil !bailey _parmfil noisily type _stata.log } mac def _rc = _rc cap drop _wt cap drop _dead cap drop _interva exit %_rc end