Code:
. sysuse auto, clear (1978 Automobile Data) . qui sureg (price length) (mpg head weight) . dis "`e(depvar)'" price mpg
Code:
. tempvar "`e(depvar)'" _"price mpg invalid name r(198);
Next, lets assume that I have succeeded, I will do it manually below, but I want this to be automated as above:
Code:
. tempvar price mpg
.
. foreach l of local e(depvar) {
2.
. predict ``l'', resid eq(`l')
3.
. }
{ required
r(100);
end of do-file
r(100);E.g., manually this would be (but I do not want it manual, I want it automatic):
Code:
. qui sureg (price length) (mpg head weight)
.
. tempvar price mpg
.
. foreach l in price mpg {
2.
. predict ``l'', resid eq(`l')
3.
. }
.
. summ `price'
Variable | Obs Mean Std. Dev. Min Max
-------------+---------------------------------------------------------
__000000 | 74 -3.66e-06 2660.321 -3276.24 8826.866
.
. summ `mpg'
Variable | Obs Mean Std. Dev. Min Max
-------------+---------------------------------------------------------
__000001 | 74 8.81e-09 3.411963 -6.985186 13.98194
.
end of do-file
.
0 Response to How to dereference macros such as e(depvar), and macros which are already macros themselves, e.g., `macro' ?
Post a Comment