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
THE INFORMATION TRANSMITTED IN THIS ELECTRONIC COMMUNICATION IS INTENDED ONLY FOR THE PERSON OR ENTITY TO WHOM IT IS ADDRESSED AND MAY CONTAIN CONFIDENTIAL AND/OR PRIVILEGED MATERIAL. ANY REVIEW, RETRANSMISSION, DISSEMINATION OR OTHER USE OF OR TAKING OF ANY ACTION IN RELIANCE UPON, THIS INFORMATION BY PERSONS OR ENTITIES OTHER THAN THE INTENDED RECIPIENT IS PROHIBITED. IF YOU RECEIVED THIS INFORMATION IN ERROR, PLEASE CONTACT THE SENDER AND THE PRIVACY OFFICER, AND PROPERLY DISPOSE OF THIS INFORMATION.
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/