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'"
Nick
[email protected]
Herve STOLOWY
>
> First of all, thank you again for your help. I am a real beginner with
> programming and matrices. So, I do understand that my coding is not
> "clean" at all.
>
> I tried to implement what you suggest. It partly works, in the sense
> that, treating three variables, I get the label for the first two but
> not for the last one (where I get the var name). I checked that the
> label is available in the data and there is no doubt.
>
> 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
> }
>
> (I did not follow all your suggestions because I did not
> understand all
> of them. I replaced -univar- by -summarize- and inserted the few lines
> concerning the row names).
>
*
* 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/