Camelia,
You also asked how you could save the variables as a text file. This
can be done with -listtex- from SSC. Add the following lines after
the loop that builds up the matrix.
svmat bigmat
listtex bigmat* if bigmat1<. using "big_matrix.txt"
Friedrich Huebler
--- Friedrich Huebler <[email protected]> wrote:
> Camelia,
>
> Here is one way to build up a big matrix with the results from
> -tabstat-.
>
> sysuse auto, clear
> local i = 1
> foreach var of varlist price mpg weight {
> quietly tabstat `var', stat(mean sd) by(foreign) save
> tabstatmat mat
> if `i'==1 {
> matrix bigmat = mat
> }
> else {
> matrix bigmat = bigmat \ mat
> }
> local i = `i' + 1
> }
>
> Hope this helps,
>
> Friedrich Huebler
>
> --- Camelia Minoiu <[email protected]> wrote:
> > I would like to obtain summary statistics (by another variable)
> for
> > a list
> > of 100 variables, and then save all of these in one big matrix,
> and
> > preferably have this exported into a text file.
> > I have been following the discussion surrounding -tabstatmat-as
> > well as that
> > regarding the command - mat2txt- (Feb 2004) but running mat2txt
> > on my
> > computer gives me the error message: "version 8.2 not supported"
> (I
> > use
> > Stata 8) and with tabstatmat I don't know if I can do this
> > repeatedly. For
> > example, writing a tiny program such as the one below does not
> seem
> > to work:
> >
> > foreach X of varist v1-v100 {
> > quietly tabstat `X', statistics(mean, sd) by(category_`X')
> save
> > tabstatmat mat`X'
> > svmat mat`X'
> > keep mat`X'*
> > dropmiss, obs
> > outsheet using c:\data\matrix.txt
> > }
> >
> > Do you happen to know what I can do so that all the results from
> > each
> > tabstat on each variable are appended together in one big matrix?
> >
> > Thank you in anticipation.
> >
> > Camelia Minoiu
> > PhD Student
> > Department of Economics, Columbia University
_______________________________
Do you Yahoo!?
Declare Yourself - Register online to vote today!
http://vote.yahoo.com
*
* 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/