Statalist


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

Re: st: RE: Accessing saved results for mean


From   Maarten buis <[email protected]>
To   [email protected]
Subject   Re: st: RE: Accessing saved results for mean
Date   Tue, 28 Aug 2007 22:18:43 +0100 (BST)

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

Hope this helps,
Maarten

-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------


      ___________________________________________________________
Yahoo! Answers - Got a question? Someone out there knows the answer. Try it
now.
http://uk.answers.yahoo.com/ 
*
*   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