The problem is that many commands, e.g., graph save, do not return anything in r(). Yet, these commands call other commands, e.g., file, that do store contents in r(). As a result, previous results in r(), e.g., from margins, are wiped. Stata programs can already be declared nclass (i.e., declared to return nothing) but that does not seem to have any effect at all. I wish that nclass preserves r() (and e(), and perhaps even s()) results. Do this under version control or add a qualifier-syntax, e.g., nclass(preserve {r|e|s})to make sure that code continues to work.
Returning to #86, a solution that presreves both e() results from the estimation command and r() results from margins, is
Code:
tempname rr _return hold `rr' _return restore `rr' , hold commands that wipe r() _return restore `rr'
Code:
help _return
Daniel
Leave a comment: