Does anyone know how to map a logical operation (e.g., | or &) across
a list so that I can save myself some typing?
Let me give you an example (the one that prompted the search for an
answer):
I want to list a set of variables, only if an observation is not missing
for the variables in question. We usually handle this by constructing
a small logical expression:
l med1 med2 if (med1~=.|med2~=.)
However, if I have six, or a hundred "med" variables (med*), it would
be easier (less error-prone) to type:
l med* if |(med*~=.)
Where the "|" before the "(" maps the operation onto the expanded list
of variables.
I know that Scheme (and hence probably S) have a function called "map"
that maps any operation onto a list, e.g.,
(map or '(1 2 3 ... ))
Does anyone know of a similar construct in Stata? How about an egen
function that would accomplish the same goal?
Thanks,
Joel
--
Joel J. Adamson
Biostatistician
Pediatric Psychopharmacology Research Unit
Massachusetts General Hospital
Boston, MA 02114
(617) 643-1432
(303) 880-3109
[...]