Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: syntax - expanding vars ending in a number


From   [email protected]
To   [email protected]
Subject   st: syntax - expanding vars ending in a number
Date   Wed, 10 Jan 2007 13:36:15 +0000

I don't know if it is possible to refer to a set of variables called the
same thing but all ending in a number, but I'd quite like it to be.

For example, consider a dataset with the variables houseinc1 to
houseinc100, houseinc_mean and id.  It would be nice to be able to do
something like:

egen houseinc_total=rsum(houseinc#)
which would sum houseinc1-houseinc100 but exclude housein_mean

I know I could do:

aorder
egen houseinc_total=rsum(houseinc1-houseinc_100)

or

egen houseinc_total=rsum(houseinc_???)

but the first requires that I know the last number used, the second
requires that there is nothing else called houseinc_ plus three alpha
numeric characters.

Does anybody know if this is possible?  If it isn't, is there any reason it
couldn't be implemented?

Mathew


*
*   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/



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