for brevity, you could try this:
unab diagvars1 : diag?
unab diagvars2 : diag??
replace vara=1 if inlist("A",`:subinstr loc diagvars1 " " ",", all') |
inlist("A",`:subinstr loc diagvars2 " " ",", all')
the reason why diag* does not work and why you need two -inlist()-
evaluations is -inlist()- 's number-of-arguments limit. otherwise you
could use diag* and just one instance of -unab-.
hope this helps
laszlo
sdm1 wrote:
I have ten variables called diag1, diag2, ... diag10.
I would like to do a replace such that:
replace vara=1 if diag1=="A" | diag2=="A" | diag3=="A" ... .
I would rather not have to write out all ten conditions.
Is there a wild character, like *, I can use in the variable name so that
this works:
replace vara=1 if diag*=="A"
Thanks.
Steve
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/