The terminology to use is local macro, not local variable.
The following builds up a list.
forval i = 1/`k' {
local varnames "`varnames' <stub>_`i'"
}
Hope this helps.
Nick
[email protected]
Robert Duval
> I'm trying to store the output of several estimations on a
> series of matrices.
> I want to be able to label certain columns of my matrices as
>
> prefix_1 prefix_2 ... prefix_`k'
>
> where k is a local variable arbitrarily set by each routine.
>
> For example, if I estimate svymean with the by(varlist) option, the
> number of categories will change for each variable in varlist, and my
> program to store the results of each variable is
>
>
> program by_wprom0, eclass
> args name
> local k = e(n_by)
> matrix define diagV0 = vecdiag(e(V))
> matrix define `name'= ($z1 , e(b) , diagV0 , e(_N) ,
> e(_N_subp) , e(deff))
> local paranames : colnames(e(b))
>
> CODE NEEDED HERE
>
> matrix colnames `name'= Period `paranames' `varnames'
> `N' `N_subpop' `Deff'
> matrix drop diagV0
> end
>
> where I would like 'varnames' (as well as `N', `N_subpop' and `Deff' )
> to contain a list of the type
>
> var_1 var_2 ... var_`k'
>
>
> I bet there is an easy way to do this, but I just cannot find it.
>
> Any suggestions are welcome.
> Thanks in advance,
> robert
>
> *
> * 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/
>
*
* 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/