[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
"Nick Cox" <n.j.cox@durham.ac.uk> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
st: RE: Re: tabstatmat repeatedly |

Date |
Fri, 24 Sep 2004 19:05:46 +0100 |

Following Michael's optimistic assumption: the -collapse- syntax can be generated automagically: foreach v of var v1-v100 { local text "`text' (mean) `v' (sd) sd`v' = `v'" } collapse `text' , by(category) Nick n.j.cox@durham.ac.uk Michael Blasnik > I think you may want to use -collapse- and outsheet to get > the stats you > want, but I'm not sure what you mean by category_`X' in your > commands -- do > you have a different categorical variable breakout for each of the 100 > variables? Assuming that you dont, > > collapse v1 - v100 , by(category) > > will give you a dataset of means by category. Then > > collapse (sd) v1-v100 , by(category) > > will give you std devs. You can combine the two commands, > but then you have > to type out new names for all 100 std dev vars.. Instead you can > use -renvars- to rename them after the fact and then use > -merge- to combine > the means and std. devs. You may then want to re-order the > vars and then > use -outsheet- to dump them to a text file. Camelia Minoiu > > 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? * * 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/

- Prev by Date:
**st: Re: tabstatmat repeatedly** - Next by Date:
**st: Re: tabstatmat repeatedly** - Previous by thread:
**st: RE: tabstatmat repeatedly** - Next by thread:
**st: RE: Re: tabstatmat repeatedly** - Index(es):

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