After you run -mean-
"`e(b)'"
is a string containing the word "matrix".
That is what Stata is complaining about.
Evidently it is no use to you.
You need to work with e(b), therefore.
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
A small point of style is that I don't
see any need for elaboration over local
macro names. The macros exist just
as temporary holding places and can happily
be overwritten.
However, pontificating about style is a side-issue
until you can get your program working.
Of course, I don't know what your real problem is.
If it's just creating a file with six numbers,
typing them in one by one is often faster.
Nick
[email protected]
Michael Lemay
> I am trying to create a dataset of means. I'm using the following
> syntax:
>
> postfile asa_esttab v1 v2 using asa_esttab, every(1) replace
>
> foreach x in pint pncmp pact {
> mean `x' if (country==6)
> local `x'n "`e(b)'"
> mean `x' if (country==11) [pweight=pscore]
> local `x's "`e(b)'"
> post asa_esttab (``x'n') (``x's')
> }
>
> postclose asa_esttab
>
>
> I get the following error message:
>
> matrix not found
> post: above message corresponds to expression 1, variable v1
> r(111);
>
> I know the loop works because when I request the sample size be stored
> [e(N)] instead of the mean [e(b)], it runs without a problem.
> Any help
> is greatly appreciated.
*
* 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/