Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down at the end of May, and its replacement, **statalist.org** is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
daniel klein <klein.daniel.81@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: Problem with wildcards |

Date |
Tue, 5 Mar 2013 00:49:04 +0100 |

Lisa, the obvious difference is, that -egen- is one line to type, while my approach involves three lines of code. I would prefer an -egen- solution in a do-file, though I think I would rely on -anymatch()- rather than -rowax()-, which might be even more intuitive to understand. Programming an ado-file, I am rather reluctant to use -egen-, because despite being powerful, it is interpreted code (I know, so is -unab-) and therefore tends to execute slow(er). You would not notice the difference probably, and if so it would probably be a matter of less than a second, so this might be a rather weak argument. The main point of my approach is to show (or remind you of) more general concepts, like (extended) functions. These concepts might look clumsy for your specific problem (and they probably are), but they proof to be very helpful in many other situations. One example is the "inverse" use of -inlist()-, that I first learned from Nick Cox (http://www.stata.com/statalist/archive/2011-04/msg00618.html), and have used a lot ever since. Best Daniel -- Thank you, Dimitriy and Daniel. I'd be very interested in understanding the differences/benefits/drawbacks between these two approaches, if someone could explain them to me. *off to read about rowmax and rowtotal*, Lisa On Mon, Mar 4, 2013 at 4:48 PM, Dimitriy V. Masterov <dvmaster@gmail.com> wrote: You could use egen (extended generate) to do this: egen anypsych = rowmax(psych1 - psych42) AND On Mon, Mar 4, 2013 at 6:01 PM, daniel klein <klein.daniel.81@gmail.com> wrote: > Here is my approach. > > unab psych : psych1-psych42 > loc psych : subinstr loc psych " " ", " ,all > g byte anypsych = inlist(1, `psych') * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/

- Prev by Date:
**Re: st: Problem with wildcards** - Next by Date:
**Re: st: test difference in marginal effects for the same dummy variable, computed first as difference and then as derivative** - Previous by thread:
**Re: st: Problem with wildcards** - Next by thread:
**st: Marginsplot of endogenous interaction in 2sls model** - Index(es):