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

From |
"Nick Cox" <n.j.cox@durham.ac.uk> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
RE: st: RE: row mean (mean across columns) |

Date |
Thu, 9 Oct 2008 14:16:22 +0100 |

Thanks for the thanks. I exaggerated a bit, but the warning was still genuine. -egen- is odd that it is a pre-processor for -egen- functions and -- in particular -- it does not include a -syntax- statement that results in a local macro varlist containing a varlist. This is because it has to be general to cover the variety of syntaxes that are possible with -egen- functions, all the way down to empty arguments and all the way up to more general expressions. Putting it the other way round, almost always this issue would be tackled for you very early in a program by syntax varlist or syntax [varlist] that would process your input before you created any temporary variables. But, if you have any temporary variables elsewhere, using _all or * could still be problematic. In essence, however, it gets to be rare that you want to write a program to do exactly the same thing to all variables (if only because most people have identifiers too, and so forth). The point was shown up forcefully in Jacob's post because he's, presumably, at an early stage in Stata programming. As many know, with Stata programming there are several things that need to be learned more or less simultaneously if you are not to get very confused and -syntax- is one of them. I left out of my earlier post a general point that puzzles me: What is the easiest way to get a list of all permanent variable names? (And nothing else.) In practice unab all : * unab temp : __* local perm : list all - temp usually works, but this hinges on the empirical fact that Stata's names for temporary variables all start with a double underscore. But nothing stops a user creating permanent variables with such names directly as in gen __foobar = 42 and any such practice would break that code. What am I missing? Nick n.j.cox@durham.ac.uk Eva Poen Nick, thank you very much for this very helpful and comprehensive explanation. I have a question/comment on the last paragraph: 2008/10/9 Nick Cox <n.j.cox@durham.ac.uk>: > But there's a larger lesson. * and _all within programs (and also > interactively) will include, necessarily, any temporary variables that > exist. So, looping across varlists defined by such wildcards is a source > of bugs. Arguably, they are yours, not Stata's. It certainly is consequential that * and _all comprise all variables, including existing temporary variables. However, as a user I would expect * and _all to consist only of those variables that existed at the time I issued the command (since these are the only variables I know about; I have little control over what is done internally by command -x-). Anything but this behaviour would vastly reduce the usefulness of * and _all, IMHO. What is the status quo on this? Many Stata commands generate temporary variables; therefore this might be a comprehensive issue for those users making use of * and _all shorthands. * * 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/

**References**:**st: row mean (mean across columns)***From:*Jacob Wegelin <jwegelin@vcu.edu>

**st: RE: row mean (mean across columns)***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

**Re: st: RE: row mean (mean across columns)***From:*"Eva Poen" <eva.poen@gmail.com>

- Prev by Date:
**Re: st: RE: row mean (mean across columns)** - Next by Date:
**st: RE: row mean (mean across columns)** - Previous by thread:
**Re: st: RE: row mean (mean across columns)** - Next by thread:
**st: Adjusted Rates** - Index(es):

© Copyright 1996–2017 StataCorp LLC | Terms of use | Privacy | Contact us | What's new | Site index |