Statalist


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

RE: st: RE: Accessing saved results for mean


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: RE: Accessing saved results for mean
Date   Wed, 29 Aug 2007 17:27:19 +0100

This is a good improvement. I have never used -mean- 
in earnest. No doubt I should read up about it! 

-tempname b- is now redundant. 

Nick 
[email protected] 

Maarten buis
 
> --- Nick Cox <[email protected]> wrote:
> > Something more like this may be closer
> > to what you want. Not tested. Very 
> > probably can be improved. 
> > 
> > tempname b 
> > postfile asa_esttab v1 v2 using asa_esttab, every(1) replace
> >  
> > foreach x in pint pncmp pact {
> > 	mean `x' if (country==6)
> > 	mat `b' = e(b) 
> > 	local x6 = `b'[1,1] 
> > 	mean `x' if (country==11) [pweight=pscore]
> > 	mat `b' = e(b) 
> > 	local x11 = `b'[1,1]
> > 	post asa_esttab (`x6') (`x11')
> > }
> > 
> > postclose asa_esttab
> 
> One way to simplify this code is to bypass the matrix 
> commands. Instead
> of first making a matrix containing the verctor of coefficients and
> than extracting the number, you can directly get to a number in the
> coefficient vector with -_b[variable name]-:
> 
> tempname b 
> postfile asa_esttab v1 v2 using asa_esttab, every(1) replace
>  
> foreach x in pint pncmp pact {
> 	mean `x' if (country==6)
> 	local x6 = _b[`x'] 
> 	mean `x' if (country==11) [pweight=pscore]
> 	local x11 = _b[`x']
> 	post asa_esttab (`x6') (`x11')
> }
> 
> postclose asa_esttab
> 
> tempname b 
> postfile asa_esttab v1 v2 using asa_esttab, every(1) replace

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