Statalist The Stata Listserver


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

st: RE: RE: RE: How to get stacked column of means?


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: RE: RE: How to get stacked column of means?
Date   Mon, 26 Jun 2006 15:23:07 +0100

The advice on -collapse- repeats mine. 

The syntax of -egen, mean()- is 

egen <newvar> = mean(<exp>) 

so that a new variable name must be used, 
and the parentheses must be in the right 
place. 

Whether the corrected advice is good 
depends on what is wanted, but putting 
a mean in an entire variable is only 
a good idea if a new variable is needed 
for a later purpose. Otherwise, -tabstat- 
or -summarize- would suffice. 

Nick 
[email protected] 

White, Justin
 
> If you want to use the collapse command, you would have to 
> write it like
> this:
> collapse (mean) q92as q92bs q92csq92ds q92esq92fsq92gs 
> q92hsq92is q92js
> q92ks
> 
> If you don't want to loose the original data set, try the 
> egen command.
> For example:
> 
> egen q92as = (mean) q92as

Nick Cox
 
> The report "not working" is too vague to discuss. 
> 
> However, I can guess what went wrong from your
> point of view. What you asked for is not what 
> you want. 
> 
> Once you -collapse- once, you have lost your original 
> dataset. As you want several means, only one -collapse- 
> is needed, mentioning several variables. 
> 
> Nick 
> [email protected] 
> 
> buddyb
>  
> > I'm running STATA 8.2
> > 
> > I am trying to get a stacked column of means for
> > several variables (q92as q92bs q92cs q92ds q92es q92fs
> > q92gs q92hs q92is q92js q92ks)
> > 
> > This is what I'm wrote, but it's not working...does
> > anyone have any ideas?
> > 
> > Thanks
> > 
> > keep resp q92as q92bs q92cs q92ds q92es q92fs q92gs
> > q92hs q92is q92js q92ks
> > 
> > drop resp
> > 
> > collapse (mean)  q92as 
> > collapse (mean)  q92bs 
> > collapse (mean)  q92cs
> >  collapse (mean)  q92ds 
> > collapse (mean)  q92es
> >  collapse (mean)  q92fs
> > collapse (mean)   q92gs 
> > collapse (mean)  q92hs
> >  collapse (mean)  q92is 
> > collapse (mean)  q92js 
> > collapse (mean)  q92ks
> > 
> > 
> > 
> > stack q92as q92bs q92cs q92ds q92es q92fs q92gs q92hs
> > q92is q92js q92ks, into (Score)
> > 
> > Table Score
> 

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