I've just written the same awkward code for the untoldth time, and I'm
thinking there must be a better way to do it.
The problem is to get a particular value of a variable into a local
which corresponds to a particular value of another variable. I think
this is usally call reverse lookup. For example, I might have -period-
and -rate- and want to store the value of -rate- which corresponds to
period = 1. My lazy solution is
sum rate if period = 1
local rate1 `=r(mean)'
That is, I summarize a single observation, then put the mean in local.
Is there a better way to do this?