Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: RE: Label instead of var names in a matrix


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: RE: Label instead of var names in a matrix
Date   Fri, 17 Dec 2004 11:02:50 -0000

You can also do most of what you want without 
programming: 

ssc inst makematrix 
makematrix c2 , from(r(chi2) r(P_chi2))  : sktest size1 lev2 sales_int3
makematrix c1 , from(r(N) r(mean) r(sd)) label : su size1 lev2 sales_int3
matrix c3 = c2 , c1 

Nick 
[email protected] 

Nick Cox
 
> I am guessing in the dark here, but 
> I am not sure my rough code will handle 
> spaces in variable labels in the way you 
> want. Try 
> 
> capture matrix rownames statdes = "`label'" 
 
Herve STOLOWY
 
> > Here is my coding:
> > 
> > capture erase statdes.txt
> > foreach var of varlist size1 lev2 sales_int3 {
> > qui summarize `var'
> > loc N = r(N)
> > loc mean = r(mean)
> > loc sd = r(sd)
> > sktest `var' 
> > loc adj_chi2= r(chi2)
> > loc prob_chi2=r(P_chi2)
> > matrix statdes = (`N', `mean', `sd', `adj_chi2', `prob_chi2')
> > local label : variable label `var'
> > capture matrix rownames statdes =  `label'
> > if _rc{
> > matrix rownames statdes = `var'
> > }
> > matrix colnames statdes = N mean sd chi2 Prob(chi2)
> > mat2txt, matrix(statdes) saving(statdes) append
> > }
> > 

*
*   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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index