/*
  stepwise

*!  VERSION 2.0.6  17may2011

*/

VERSION 12.0

INCLUDE _std_large
INCLUDE header

HELP hlp1, view("help stepwise")
RESET res1

DIALOG main, label("stepwise - Stepwise estimation") tabtitle("Model")
BEGIN
  DEFINE wlabel 130

  TEXT     tx_terms  _lft      _top      _cwd1     .,			///
	label("Regression terms:")
  TEXT     tx_cmds   _lft2     @         _cwd1     .,			///
	label("Command:")
  COMBOBOX cb_term   _lft      _ss       _cwd1     .,			///
	label("Regression terms")					///
	contents(term_con)						///
	onselchangelist(term_sel) dropdownlist
  COMBOBOX cb_cmd    _lft2     @         _cwd1     .,			///
	label("Command")						///
	contents(cmd_con)						///
	value(cmd_con)							///
	onselchangelist(cmd_sel) dropdownlist

  TEXT     tx_dv1    _lft      _ls       wlabel    .,			///
	label("Dependent variable:")
  DEFINE holdy @y
  VARNAME  vn_dv1    @         _ss       _vnwd     .,			///
	label("Dependent variable")

  TEXT     tx_dv2    _vlx      holdy     wlabel    .,			///
	label("Dependent variable 2:")
  VARNAME  vn_dv2    @         _ss       _vnwd     .,			///
	label("Dependent variable 2")

  TEXT     tx_term   _lft      _ls       _iwd      .,			///
	label("Term 1 -- variables to be included or excluded together")

  VARLIST  vn_term1  @         _ss       @         ., label("Term 1")
  VARLIST  vn_term2  @         @         @         ., label("Term 2")
  VARLIST  vn_term3  @         @         @         ., label("Term 3")
  VARLIST  vn_term4  @         @         @         ., label("Term 4")
  VARLIST  vn_term5  @         @         @         ., label("Term 5")
  VARLIST  vn_term6  @         @         @         ., label("Term 6")
  VARLIST  vn_term7  @         @         @         ., label("Term 7")
  VARLIST  vn_term8  @         @         @         ., label("Term 8")
  VARLIST  vn_term9  @         @         @         ., label("Term 9")
  VARLIST  vn_term10 @         @         @         ., label("Term 10")

  GROUPBOX gb_name   _lft      _ls       _iwd      _ht9,		///
	label("Selection criterion")

  CHECKBOX ck_pr     _ilft     _ss       _ibwd     .,			///
	label("Significance level for removal from the model:")		///
	clickon("program checkP_opts")					///
	clickoff("program checkP_opts")

  EDIT     en_pr     _cksep    _ss       _en7wd    .,			///
	label("Significance level for removal from the model")		///
	numonly								///
	option(pr)

  CHECKBOX ck_pe     _ilft     _ls       _ibwd     .,			///
	label("Significance level for addition to the model:")		///
	clickon("program checkP_opts")					///
	clickoff("program checkP_opts")

  EDIT     en_pe     _cksep    _ss       _en7wd    .,			///
	label("Significance level for addition to the model")		///
	numonly								///
	option(pe)
END

LIST term_con
BEGIN
	Term 1 (required)
	Term 2
	Term 3
	Term 4
	Term 5
	Term 6
	Term 7
	Term 8
	Term 9
	Term 10
END

LIST term_sel
BEGIN
	script term1
	script term2
	script term3
	script term4
	script term5
	script term6
	script term7
	script term8
	script term9
	script term10
END

LIST cmd_con
BEGIN
	clogit
	cloglog
	glm
	intreg
	logistic
	logit
	nbreg
	ologit
	oprobit
	poisson
	probit
	qreg
	regress
	scobit
	stcox
	stcrreg
	streg
	tobit
END

LIST cmd_sel
BEGIN
	script clogit_on
	script cloglog_on
	script glm_on
	script intreg_on
	script logitstic_on
	script logit_on
	script nbreg_on
	script ologit_on
	script oprobit_on
	script poisson_on
	script probit_on
	script qreg_on
	script regress_on
	script scobit_on
	script stcox_on
	script stcrreg_on
	script streg_on
	script tobit_on
END

PROGRAM checkP_opts
BEGIN
	if main.ck_pr {
		call gaction main.en_pr.enable
	}
	if ! main.ck_pr {
		call gaction main.en_pr.disable
	}
	if main.ck_pe {
		call gaction main.en_pe.enable
	}
	if ! main.ck_pe {
		call gaction main.en_pe.disable
	}
	if main.ck_pr & main.ck_pe {
		call gaction model2.ck_forward.enable
		call gaction model2.ck_hier.disable
	}
	if ! (main.ck_pr & main.ck_pe) {
		call gaction model2.ck_forward.disable
		call gaction model2.ck_hier.enable
	}
END

PROGRAM hide_allx
BEGIN
	if !H(main.vn_term1) {
		call gaction main.vn_term1.hide
	}
	if !H(main.vn_term2) {
		call gaction main.vn_term2.hide
	}
	if !H(main.vn_term3) {
		call gaction main.vn_term3.hide
	}
	if !H(main.vn_term4) {
		call gaction main.vn_term4.hide
	}
	if !H(main.vn_term5) {
		call gaction main.vn_term5.hide
	}
	if !H(main.vn_term6) {
		call gaction main.vn_term6.hide
	}
	if !H(main.vn_term7) {
		call gaction main.vn_term7.hide
	}
	if !H(main.vn_term8) {
		call gaction main.vn_term8.hide
	}
	if !H(main.vn_term9) {
		call gaction main.vn_term9.hide
	}
	if !H(main.vn_term10) {
		call gaction main.vn_term10.hide
	}

END

SCRIPT term1
BEGIN
	program hide_allx
	main.tx_term.setlabel ///
		"Term 1 -- variables to be included or excluded together:"
	main.vn_term1.show
END

SCRIPT term2
BEGIN
	program hide_allx
	main.tx_term.setlabel ///
		"Term 2 -- variables to be included or excluded together:"
	main.vn_term2.show
END

SCRIPT term3
BEGIN
	program hide_allx
	main.tx_term.setlabel ///
		"Term 3 -- variables to be included or excluded together:"
	main.vn_term3.show
END

SCRIPT term4
BEGIN
	program hide_allx
	main.tx_term.setlabel ///
		"Term 4 -- variables to be included or excluded together:"
	main.vn_term4.show
END

SCRIPT term5
BEGIN
	program hide_allx
	main.tx_term.setlabel ///
		"Term 5 -- variables to be included or excluded together:"
	main.vn_term5.show
END

SCRIPT term6
BEGIN
	program hide_allx
	main.tx_term.setlabel ///
		"Term 6 -- variables to be included or excluded together:"
	main.vn_term6.show
END

SCRIPT term7
BEGIN
	program hide_allx
	main.tx_term.setlabel ///
		"Term 7 -- variables to be included or excluded together:"
	main.vn_term7.show
END

SCRIPT term8
BEGIN
	program hide_allx
	main.tx_term.setlabel ///
		"Term 8 -- variables to be included or excluded together:"
	main.vn_term8.show
END

SCRIPT term9
BEGIN
	program hide_allx
	main.tx_term.setlabel ///
		"Term 9 -- variables to be included or excluded together:"
	main.vn_term9.show
END

SCRIPT term10
BEGIN
	program hide_allx
	main.tx_term.setlabel ///
		"Term 10 -- variables to be included or excluded together:"
	main.vn_term10.show
END

SCRIPT main_one_depvar
BEGIN
	script model2_dist_off
	main.tx_dv1.setlabel "Dependent variable:"
	main.tx_dv1.enable
	main.vn_dv1.enable
	main.tx_dv2.hide
	main.vn_dv2.hide
END

SCRIPT main_two_depvars
BEGIN
	script model2_dist_off
	main.tx_dv1.setlabel "Dependent variable 1:"
	main.tx_dv1.enable
	main.vn_dv1.enable
	main.tx_dv2.show
	main.vn_dv2.show
END

SCRIPT main_no_depvars
BEGIN
	main.tx_dv1.setlabel "Dependent variable:"
	main.tx_dv1.disable
	main.vn_dv1.disable
	main.tx_dv2.hide
	main.vn_dv2.hide
END

SCRIPT clogit_on
BEGIN
	script main_one_depvar
	script model2_lr_on
	script model2_group_on
	script model2_cens_off
	script model2_disp_off
	script model2_quant_off
	script model2_llul_off
	script model2_stcrreg_off
	script rpt_or_on
	script weights_setLayout_fi
	script weights_enable
END

SCRIPT cloglog_on
BEGIN
	script main_one_depvar
	script model2_lr_on
	script model2_group_off
	script model2_cens_off
	script model2_disp_off
	script model2_quant_off
	script model2_llul_off
	script model2_stcrreg_off
	script rpt_eform_on
	script weights_setLayout_fpi
	script weights_enable
END

SCRIPT glm_on
BEGIN
	script main_one_depvar
	script model2_lr_on
	script model2_group_off
	script model2_cens_off
	script model2_disp_off
	script model2_quant_off
	script model2_llul_off
	script model2_stcrreg_off
	script rpt_eform_on
	script weights_setLayout_fpai
	script weights_enable
END

SCRIPT intreg_on
BEGIN
	script main_two_depvars
	script model2_lr_on
	main.tx_dv1.setlabel "Dependent variable 1:"
	main.tx_dv2.show
	main.vn_dv2.show
	script model2_group_off
	script model2_cens_off
	script model2_disp_off
	script model2_quant_off
	script model2_llul_off
	script model2_stcrreg_off
	script rpt_eform_off
	script weights_setLayout_fpai
	script weights_enable
END

SCRIPT logitstic_on
BEGIN
	script main_one_depvar
	script model2_lr_on
	script model2_group_off
	script model2_cens_off
	script model2_disp_off
	script model2_quant_off
	script model2_llul_off
	script model2_stcrreg_off
	script rpt_eform_off
	script weights_setLayout_fpi
	script weights_enable
END

SCRIPT logit_on
BEGIN
	script main_one_depvar
	script model2_lr_on
	script model2_group_off
	script model2_cens_off
	script model2_disp_off
	script model2_quant_off
	script model2_llul_off
	script model2_stcrreg_off
	script rpt_or_on
	script weights_setLayout_fpi
	script weights_enable
END

SCRIPT nbreg_on
BEGIN
	script main_one_depvar
	script model2_lr_on
	script model2_group_off
	script model2_cens_off
	script model2_disp_on
	script model2_quant_off
	script model2_llul_off
	script model2_stcrreg_off
	script rpt_irr_on
	script weights_setLayout_fpi
	script weights_enable
END

SCRIPT ologit_on
BEGIN
	script main_one_depvar
	script model2_lr_on
	script model2_group_off
	script model2_cens_off
	script model2_disp_off
	script model2_quant_off
	script model2_llul_off
	script model2_stcrreg_off
	script rpt_or_on
	script weights_setLayout_fpi
	script weights_enable
END

SCRIPT oprobit_on
BEGIN
	script main_one_depvar
	script model2_lr_on
	script model2_group_off
	script model2_cens_off
	script model2_disp_off
	script model2_quant_off
	script model2_llul_off
	script model2_stcrreg_off
	script rpt_eform_off
	script weights_setLayout_fpi
	script weights_enable
END

SCRIPT probit_on
BEGIN
	script main_one_depvar
	script model2_lr_on
	script model2_group_off
	script model2_cens_off
	script model2_disp_off
	script model2_quant_off
	script model2_llul_off
	script model2_stcrreg_off
	script rpt_eform_off
	script weights_setLayout_fpi
	script weights_enable
END

SCRIPT poisson_on
BEGIN
	script main_one_depvar
	script model2_lr_on
	script model2_group_off
	script model2_cens_off
	script model2_disp_off
	script model2_quant_off
	script model2_llul_off
	script model2_stcrreg_off
	script rpt_irr_on
	script weights_setLayout_fpi
	script weights_enable
END

SCRIPT qreg_on
BEGIN
	script main_one_depvar
	script model2_lr_off
	script model2_group_off
	script model2_cens_off
	script model2_disp_off
	script model2_quant_on
	script model2_llul_off
	script model2_stcrreg_off
	script rpt_eform_off
	script weights_setLayout_fa
	script weights_enable
END

SCRIPT regress_on
BEGIN
	script main_one_depvar
	script model2_lr_on
	script model2_group_off
	script model2_cens_off
	script model2_disp_off
	script model2_quant_off
	script model2_llul_off
	script model2_stcrreg_off
	script rpt_eform_off
	script weights_setLayout_fpai
	script weights_enable
END

SCRIPT scobit_on
BEGIN
	script main_one_depvar
	script model2_lr_on
	script model2_group_off
	script model2_cens_off
	script model2_disp_off
	script model2_quant_off
	script model2_llul_off
	script model2_stcrreg_off
	script rpt_or_on
	script weights_setLayout_fpi
	script weights_enable
END

SCRIPT stcox_on
BEGIN
	script main_no_depvars
	script model2_lr_on
	script model2_dist_off
	script model2_group_off
	script model2_cens_off
	script model2_disp_off
	script model2_quant_off
	script model2_llul_off
	script model2_stcrreg_off
	script rpt_nohr_on
	script weights_disable
END

SCRIPT streg_on
BEGIN
	script main_no_depvars
	script model2_lr_on
	script model2_dist_on
	script model2_group_off
	script model2_cens_off
	script model2_disp_off
	script model2_quant_off
	script model2_llul_off
	script model2_stcrreg_off
	script rpt_nohr_on
	script weights_disable
END

SCRIPT stcrreg_on
BEGIN
	script main_no_depvars
	script model2_lr_off
	script model2_dist_off
	script model2_group_off
	script model2_cens_off
	script model2_disp_off
	script model2_quant_off
	script model2_llul_off
	script model2_stcrreg_on
	script rpt_nohr_on
	script weights_disable
END

SCRIPT tobit_on
BEGIN
	script main_one_depvar
	script model2_lr_on
	script model2_group_off
	script model2_cens_off
	script model2_disp_off
	script model2_quant_off
	script model2_llul_on
	script model2_stcrreg_off
	script rpt_eform_off
	script weights_setLayout_fa
	script weights_enable
END

DIALOG model2, tabtitle("Model 2")
BEGIN
  CHECKBOX ck_forward _lft     _top      _cwd1     .,			///
	label("Perform forward-stepwise selection")			///
	option(forward)
  CHECKBOX ck_hier   @         _ms       @         .,			///
	label("Perform hierarchical selection")				///
	option(hierarchical)
  CHECKBOX ck_lock1  @         _ms       @         .,			///
	label("Keep the first term")					///
	option(lockterm1)

  GROUPBOX gb_selstat _lft2    _top      _cwd1     _ht4,		///
  	label("Stepwise test statistic")
  RADIO    rb_wald   _indent   _ss       _inwd     .,			///
	label("Wald (default)") option(NONE) first
  RADIO    rb_lr     @         _ss       @         .,			///
	label("Likelihood ratio") option(lr) last

  DEFINE holdx _lft
  DEFINE holdy _ht6h

  // CLOGIT
  TEXT     tx_group  holdx     holdy     _iwd      .,			///
	label("Group variable (required):")
  VARNAME  vn_group  @         _ss       _vnwd     .,			///
	label("Group variable") option(group)

  // CNREG
  TEXT     tx_cens   holdx     holdy     _iwd      .,			///
	label("Variable that identifies censored observations (required):")
  VARNAME  vn_cens   @         _ss       _vnwd     .,			///
	label("Variable that identifies censored observations:")	///
	option(censored)

  // NBREG
  GROUPBOX gb_disper holdx     holdy     _iwd      _ht2,		///
		label("Parameterization of dispersion")
  RADIO    rb_mean   _ilft     _ss       _cwd2     ., first		///
		label("A function of the expected mean")		///
		option("dispersion(mean)")
  RADIO    rb_cons   _lft2     @         @         ., last		///
		label("A constant")					///
		option("dispersion(constant)")

  // QREG
  SPINNER  sp_quantile holdx   holdy     _spwd     .,			///
		label("Quantile to estimate")				///
		min(1)							///
		max(100)						///
		default(50)						///
		option("quantile")
  TEXT     tx_quantile    _spsep    @         _spr      .,		///
		label("Quantile to estimate")

  // STCRREG
  GROUPBOX gb_compete	holdx	holdy	_iwd	_ht4,			///
	label("Competing-risks events")
  TEXT tx_compete_crvar	_ilft	_ss	_cwd3	.,			///
	label("Variable:")
  VARNAME  vn_crvar	@	+20	_vnwd	.,			///
	label("Variable for competing-risk events")
  TEXT tx_crnumlist	_lft2	-20	_cwd3	.,			///
	label("Values:")
  EDIT ed_crnumlist	@	_ss	_vnwd	.,			///
	label("Values")

  // STREG
  GROUPBOX gb_model  holdx     holdy     _iwd      _ht6,		///
	label("Survival distribution")
  RADIO    rb_exp    _ilft     _ss       _cwd2     .,			///
	label("Exponential")						///
	first								///
	option(dist(exponential))
  RADIO    rb_weib   _lft2     @         @         .,			///
	label("Weibull")						///
	option(dist(weibull))
  RADIO    rb_gomp   _ilft     _ss       @         .,			///
	label("Gompertz")						///
	option(dist(gompertz))
  RADIO    rb_logn   _lft2     @         @         .,			///
	label("Log normal")						///
	option(dist(lognormal))
  RADIO    rb_logl   _ilft     _ss       @         .,			///
	label("Log logistic")						///
	option(dist(loglogistic))
  RADIO    rb_gamma  _lft2     @         @         .,			///
	label("Generalized gamma")					///
	last								///
	option(dist(gamma))

  // TOBIT
  GROUPBOX gb_censor holdx     holdy     _iwd      _ht8h,		///
		label("Specify at least one censoring limit")
  RADIO    rb_noll   _indent   _ss       _cwd2     ., first		///
	  	label("No left-censoring limit")			///
		onclickon("gaction model2.en_ll.disable")
  DEFINE y @y
  RADIO    rb_ll     @         _ss       @         .,			///
		label("Left-censoring at minimum")			///
		clickon("gaction model2.en_ll.disable")			///
		option("ll")	default(1)
  RADIO    rb_llarg  @         _ss       @         ., last		///
		label("Specified left-censoring limit:")		///
		clickon("gaction model2.en_ll.enable")
  EDIT     en_ll     _indent2  _ss       _en14wd   .,			///
		label("Left-censoring limit")				///
		numonly							///
		option("ll")
  RADIO    rb_noul   _lft2     y         _cwd2     ., first		///
		onclickon("gaction model2.en_ul.disable")		///
		label("No right-censoring limit")
  RADIO    rb_ul     @         _ss       @         .,			///
		label("Right-censoring at maximum")			///
		clickon("gaction model2.en_ul.disable")			///
		option("ul")
  RADIO    rb_ularg  @         _ss       @         ., last		///
		label("Specified right-censoring limit:")		///
		clickon("gaction model2.en_ul.enable")
  EDIT     en_ul     _indent2  _ss       _en14wd   .,			///
		label("Right-censoring limit")				///
		numonly option("ul")

  // This goes at the bottom of this tab.
  TEXT     tx_regopt _lft      _ht22     _iwd      .,			///
	label("Other options accepted by chosen regression command:")

  EDIT     ed_regopt @         _ss       @         .,			///
	label("Other options accepted by chosen regression command")

END

SCRIPT model2_lr_on
BEGIN
	model2.gb_selstat.show
	model2.rb_wald.show
	model2.rb_lr.show
END

SCRIPT model2_lr_off
BEGIN
	model2.gb_selstat.hide
	model2.rb_wald.hide
	model2.rb_lr.hide
END

SCRIPT model2_dist_on
BEGIN
	model2.gb_model.show
	model2.rb_exp.show
	model2.rb_weib.show
	model2.rb_gomp.show
	model2.rb_logn.show
	model2.rb_logl.show
	model2.rb_gamma.show
END

SCRIPT model2_dist_off
BEGIN
	model2.gb_model.hide
	model2.rb_exp.hide
	model2.rb_weib.hide
	model2.rb_gomp.hide
	model2.rb_logn.hide
	model2.rb_logl.hide
	model2.rb_gamma.hide
END

SCRIPT model2_group_on
BEGIN
	model2.tx_group.show
	model2.vn_group.show
END

SCRIPT model2_group_off
BEGIN
	model2.tx_group.hide
	model2.vn_group.hide
END

SCRIPT model2_cens_on
BEGIN
	model2.tx_cens.show
	model2.vn_cens.show
END

SCRIPT model2_cens_off
BEGIN
	model2.tx_cens.hide
	model2.vn_cens.hide
END

SCRIPT model2_disp_on
BEGIN
	model2.gb_disper.show
	model2.rb_mean.show
	model2.rb_cons.show
END

SCRIPT model2_disp_off
BEGIN
	model2.gb_disper.hide
	model2.rb_mean.hide
	model2.rb_cons.hide
END

SCRIPT model2_quant_on
BEGIN
	model2.sp_quantile.show
	model2.tx_quantile.show
END

SCRIPT model2_quant_off
BEGIN
	model2.sp_quantile.hide
	model2.tx_quantile.hide
END

SCRIPT model2_llul_on
BEGIN
	model2.gb_censor.show
	model2.rb_noll.show
	model2.rb_ll.show
	model2.rb_llarg.show
	model2.en_ll.show
	model2.rb_noul.show
	model2.rb_ul.show
	model2.rb_ularg.show
	model2.en_ul.show
END

SCRIPT model2_llul_off
BEGIN
	model2.gb_censor.hide
	model2.rb_noll.hide
	model2.rb_ll.hide
	model2.rb_llarg.hide
	model2.en_ll.hide
	model2.rb_noul.hide
	model2.rb_ul.hide
	model2.rb_ularg.hide
	model2.en_ul.hide
END

SCRIPT model2_stcrreg_on
BEGIN
	model2.gb_compete.show
	model2.tx_compete_crvar.show
	model2.vn_crvar.show
	model2.tx_crnumlist.show
	model2.ed_crnumlist.show
END

SCRIPT model2_stcrreg_off
BEGIN
	model2.gb_compete.hide
	model2.tx_compete_crvar.hide
	model2.vn_crvar.hide
	model2.tx_crnumlist.hide
	model2.ed_crnumlist.hide
END

INCLUDE byifin
INCLUDE weights_fi

SCRIPT rpt_POSTINIT
BEGIN
        create STRING rpt_bu_fmtcoefResults
        program rpt_bu_fmtcoef_ckResults
END

DIALOG rpt, tabtitle("Reporting")
BEGIN
  DEFINE _x _lft
  DEFINE _cx _spr2b
  DEFINE _y _top
  INCLUDE _sp_level

  RADIO    rb_coef     _lft        _ls       _iwd        ., first	///
		label("Report coefficients (default)")			///
		option(NONE)
  RADIO    rb_nohr     @           _ss       @           .,		///
		label("Report coefficients instead of hazard ratios")	///
		option(nohr)
  RADIO    rb_irr      @           @         @           .,		///
		label("Report incidence-rate ratios")			///
		option(irr)
  RADIO    rb_or       @           @         @           .,		///
		label("Report odds ratios")				///
		option(or)
  RADIO    rb_rrr      @           @         @           .,		///
		label("Report reliative-risk ratios")			///
		option(rrr)
  RADIO    rb_eform    @           @         @           ., last	///
		label("Report exponentiated coefficients")		///
		option(eform)
  DEFINE _x _lft
  DEFINE _y _ls
  INCLUDE _bu_coef_table_reporting
END

INCLUDE fmt_coef_table_reporting_pr

SCRIPT rpt_eform_off
BEGIN
	rpt.rb_coef.hide
	rpt.rb_nohr.hide
	rpt.rb_irr.hide
	rpt.rb_or.hide
	rpt.rb_rrr.hide
	rpt.rb_eform.hide
END

SCRIPT rpt_nohr_on
BEGIN
	rpt.rb_coef.setlabel "Report hazard ratios (default)"
	rpt.rb_coef.show
	rpt.rb_nohr.show
	rpt.rb_irr.hide
	rpt.rb_or.hide
	rpt.rb_rrr.hide
	rpt.rb_eform.hide
END

SCRIPT rpt_irr_on
BEGIN
	rpt.rb_coef.setlabel "Report coefficients (default)"
	rpt.rb_coef.show
	rpt.rb_nohr.hide
	rpt.rb_irr.show
	rpt.rb_or.hide
	rpt.rb_rrr.hide
	rpt.rb_eform.hide
END

SCRIPT rpt_or_on
BEGIN
	rpt.rb_coef.setlabel "Report coefficients (default)"
	rpt.rb_coef.show
	rpt.rb_nohr.hide
	rpt.rb_irr.hide
	rpt.rb_or.show
	rpt.rb_rrr.hide
	rpt.rb_eform.hide
END

SCRIPT rpt_rrr_on
BEGIN
	rpt.rb_coef.setlabel "Report coefficients (default)"
	rpt.rb_coef.show
	rpt.rb_nohr.hide
	rpt.rb_irr.hide
	rpt.rb_or.show
	rpt.rb_rrr.hide
	rpt.rb_eform.hide
END

SCRIPT rpt_eform_on
BEGIN
	rpt.rb_coef.setlabel "Report coefficients (default)"
	rpt.rb_coef.show
	rpt.rb_nohr.hide
	rpt.rb_irr.hide
	rpt.rb_or.hide
	rpt.rb_rrr.hide
	rpt.rb_eform.show
END

PROGRAM stepwise_command
BEGIN
	allowxi
	INCLUDE _by_pr
	put "stepwise "
	beginoptions
		if ! (main.ck_pr | main.ck_pe) {
			stopbox stop ///
			`"On the "Model" tab,"' ///
			`"At least one of the "Significance level""' ///
			`"options must be specified"'
		}
		if main.ck_pr {
			require main.en_pr
			optionarg main.en_pr
		}
		if main.ck_pe {
			require main.en_pe
			optionarg main.en_pe
		}
		option model2.ck_forward
		option model2.ck_hier
		option model2.ck_lock1
		option model2.rb_lr
	endoptions
END

PROGRAM term1_output
BEGIN
	put /hidden main.vn_term1
END

PROGRAM term2_output
BEGIN
	put /hidden main.vn_term2
END

PROGRAM term3_output
BEGIN
	put /hidden main.vn_term3
END

PROGRAM term4_output
BEGIN
	put /hidden main.vn_term4
END

PROGRAM term5_output
BEGIN
	put /hidden main.vn_term5
END

PROGRAM term6_output
BEGIN
	put /hidden main.vn_term6
END

PROGRAM term7_output
BEGIN
	put /hidden main.vn_term7
END

PROGRAM term8_output
BEGIN
	put /hidden main.vn_term8
END

PROGRAM term9_output
BEGIN
	put /hidden main.vn_term9
END

PROGRAM term10_output
BEGIN
	put /hidden main.vn_term10
END

PROGRAM command_command
BEGIN
	put main.cb_cmd
	if !H(main.vn_dv1) {
		require main.vn_dv1
	}
	put " " main.vn_dv1
	if !H(main.vn_dv2) {
		require main.vn_dv2
		put " " main.vn_dv2
	}
	require main.vn_term1
	put " "
	put "("
	put /program term1_output
	put ") "
	if main.vn_term2 {
		put "("
		put /program term2_output
		put ") "
	}
	if main.vn_term3 {
		put "("
		put /program term3_output
		put ") "
	}
	if main.vn_term4 {
		put "("
		put /program term4_output
		put ") "
	}
	if main.vn_term5 {
		put "("
		put /program term5_output
		put ") "
	}
	if main.vn_term6 {
		put "("
		put /program term6_output
		put ") "
	}
	if main.vn_term7 {
		put "("
		put /program term7_output
		put ") "
	}
	if main.vn_term8 {
		put "("
		put /program term8_output
		put ") "
	}
	if main.vn_term9 {
		put "("
		put /program term9_output
		put ") "
	}
	if main.vn_term10 {
		put "("
		put /program term10_output
		put ") "
	}
	INCLUDE _ifin_pr
	INCLUDE _weights_pr
	beginoptions
		// CLOGIT
		if !H(model2.vn_group) {
			require model2.vn_group
			optionarg model2.vn_group
		}
		// CNREG
		if !H(model2.vn_cens) {
			require model2.vn_cens
			optionarg model2.vn_cens
		}
		// NBREG
		option model2.rb_cons
		// QREG
		optionarg model2.sp_quantile
		// STREG
		option model2.rb_exp
		option model2.rb_weib
		option model2.rb_gomp
		option model2.rb_logn
		option model2.rb_logl
		option model2.rb_gamma
		//STCRREG
		if model2.vn_crvar.isvisible() {
			require model2.vn_crvar
			put " compete(" model2.vn_crvar
			if (model2.ed_crnumlist.isneq("")) {
				put "==" model2.ed_crnumlist
				put ") "
			}
			else {
				put ") "
			}
		}
		// TOBIT
		if model2.rb_noll.isvisible() & model2.rb_noll & model2.rb_noul {
			stopbox stop				///
			`"On the "Model 2" tab,"'		///
			`"at least one censoring limit must be specified"'
		}
		if model2.rb_llarg {
			require model2.en_ll
			optionarg model2.en_ll
		}
		if model2.rb_ularg {
			require model2.en_ul
			optionarg model2.en_ul
		}
		option model2.rb_ll
		option model2.rb_ul

		put " " model2.ed_regopt
		optionarg /hidedefault rpt.sp_level
		option rpt.rb_coef
		option rpt.rb_nohr
		option rpt.rb_irr
		option rpt.rb_or
		option rpt.rb_rrr
		option rpt.rb_eform
		put " " rpt_bu_fmtcoefResults
	endoptions
END

PROGRAM command
BEGIN
	put /program stepwise_command
	put " " ":" " " /program command_command
END
