I'd like to assign the mean and standard error (SE) of a variable to macros. I can do this using the return values from the summarize command, though I have to calculate the SE by hand:
I should also be able to do it after the mean command, since that outputs the SE explicitly. However, the SE is not in the return list. Instead, it's the square root of component [1,1] in the ereturn macro e(V). How do I get it from e(V) into a local macro called se?
Also: why does one of these otherwise similar commands use return values while the other one uses ereturn values? I think I need a broader education on ereturn vs return and how to manipulate macros vs scalars....
Code:
sysuse auto, clear summarize mpg return list local mean = `r(mean)' local se = `r(sd)'/sqrt(`r(N)') di "The mean mpg is `mean' with se `se'."
Code:
mean mpg ereturn list
Comment