# st: Re: Automating even further

 From "victor michael zammit" <[email protected]> To <[email protected]> Subject st: Re: Automating even further Date Thu, 23 Oct 2003 22:36:21 +0200

```Dear Statalist,
I am still working with version 5 of  Stata .I have been wondering , if it
is at all possible to automate even further
the following program,considering any limitations that I might have   :

clear
set obs 31
gen c = _n-1
gen b = _n
gen a1 = c/30
gen a2 = .2
gen a3 = .4
gen a4 = .6
gen a5 = .8
save vmz1,replace

clear
set obs 5
gen a = _n
gen b = _n
set obs 31
gen r2 = .
gen c = .
save ab1,replace
use vmz1,clear
local i = 1
while `i'<= 31  {
di " vmz   "a1[`i'] " " a2[`i'] " " a3[`i'] " " a4[`i'] " " a5[`i'] "  "
b[`i']
local i = `i'+1
}

*  Note the output is pasted in the following piece of the program .This is
the first thing I would love to do away with.
capture set more off
capture program drop vmz
program define vmz
use ab ,clear
replace a = `1' in 1/1
replace a = `2' in 2/2
replace a = `3' in 3/3
replace a = `4' in 4/4
replace a = `5' in 5/5
qui reg a b
replace r2 = e(r2) in `6'
replace c = `6' in `6'
keep r2 c
keep in `6'/`6'
sort c
save x`6',replace
end

vmz 0 .2 .40000001 .60000002 .80000001  1
vmz .03333334 .2 .40000001 .60000002 .80000001 2
vmz .06666667 .2 .40000001 .60000002 .80000001 3
vmz .1 .2 .40000001 .60000002 .80000001  4
vmz .13333334 .2 .40000001 .60000002 .80000001 5
vmz .16666667 .2 .40000001 .60000002 .80000001 6
vmz .2 .2 .40000001 .60000002 .80000001  7
vmz .23333333 .2 .40000001 .60000002 .80000001 8
vmz .26666668 .2 .40000001 .60000002 .80000001 9
vmz .30000001 .2 .40000001 .60000002 .80000001 10
vmz .33333334 .2 .40000001 .60000002 .80000001 11
vmz .36666667 .2 .40000001 .60000002 .80000001 12
vmz .40000001 .2 .40000001 .60000002 .80000001 13
vmz .43333334 .2 .40000001 .60000002 .80000001 14
vmz .46666667 .2 .40000001 .60000002 .80000001 15
vmz .5 .2 .40000001 .60000002 .80000001  16
vmz .53333336 .2 .40000001 .60000002 .80000001 17
vmz .56666666 .2 .40000001 .60000002 .80000001 18
vmz .60000002 .2 .40000001 .60000002 .80000001 19
vmz .63333333 .2 .40000001 .60000002 .80000001 20
vmz .66666669 .2 .40000001 .60000002 .80000001 21
vmz .69999999 .2 .40000001 .60000002 .80000001 22
vmz .73333335 .2 .40000001 .60000002 .80000001 23
vmz .76666665 .2 .40000001 .60000002 .80000001 24
vmz .80000001 .2 .40000001 .60000002 .80000001 25
vmz .83333331 .2 .40000001 .60000002 .80000001 26
vmz .86666667 .2 .40000001 .60000002 .80000001 27
vmz .89999998 .2 .40000001 .60000002 .80000001 28
vmz .93333334 .2 .40000001 .60000002 .80000001 29
vmz .96666664 .2 .40000001 .60000002 .80000001 30
vmz 1 .2 .40000001 .60000002 .80000001  31
use x1,clear
local i = 1
while `i'<= 31   {
merge c using x`i'
drop _merge
sort c
local i = `i'+1
}

save vmz1a1, replace

* I  would love to be able to regress all 31 dependent variables on all
possible  combination of the independent variable b (I believe 48 ,in this
case); that is to say ,such as b1 = 1,2,3,5,4 ; b2 = 1,2,4,3,5 ;  ....  b48
= 5,1,4,3,2 ;

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```