*!Program `regall' to test all possible combinations of regressors with any regression model and any type of option
capture pr drop regall
pr def regall , rclass
version 13.0
  		 	syntax anything [if] [in] [fw iw pw aw] [,] [*] rs(string) ic(string)
  		 	gettoken colon anything : anything, parse(":")
  		 	gettoken regtype vars : anything, parse("")
  		 	gettoken depvar varlist : vars, parse("")

			qui regsets:  `varlist' , local(sets)
			loc n=r(n)
			loc sets=r(sets)
			loc r2
			loc num = 0

			di ""
			di "No." _col(10) "`rs'" _col(20) "`ic'" _col(30) "Indep. Vars."

			qui foreach set of local sets {
			local set : subinstr local set "&" " ", all

				if "`set'" !=""{
   					loc num = `num' + 1
					di `set'

					`regtype' `depvar' `set' [`weight'`exp'] `if' `in', `options'
					mat t_`num'=r(table)
					return matrix t`num' = t_`num'

					if "`rs'"=="r2" {
					loc r2_`num'=e(r2)
					}

					if "`rs'"=="r2a" {
					loc r2_`num'=e(r2_a)
					}

					if "`rs'"=="r2p" {
					loc r2_`num'=e(r2_p)
					}

					*if "`rs'"=="r2" | "`rs'"=="r2_a" & loc r2_`num'==.  {
					*di ""

					estat ic
					mat ic_`num'=r(S)

					if "`ic'"=="aic" {
					loc ic_`num'=ic_`num'[1, 5]
					}

					if "`ic'"=="bic" {
					loc ic_`num'=ic_`num'[1, 6]
					}

					noi di `num'  _col(5) %9.3f `r2_`num'' _col(12) %9.0f `ic_`num'' _col(30) "`set'"
				}
			}

end