Statalist The Stata Listserver


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

Re: st: Re: statalist-digest V4 #2578


From   n j cox <[email protected]>
To   [email protected]
Subject   Re: st: Re: statalist-digest V4 #2578
Date   Thu, 11 Jan 2007 15:08:23 +0000

Do forgive me: I was answering your question.

> 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

but I see now that you also spelled the last-mentioned
variable "houseinc_mean" and it now appears that the latter
spelling is what you have in your dataset. As you say,
this gives another answer to your question: rename
the variable. The renaming need not be permanent.

rename houseinc_mean foobar
egen houseinc_total = rowsum(houseinc*)
rename foobar houseinc_mean

Low tricks beat clever ones, some of the time.

Contrary to your guess, mine is that adding another
detail to the wildcard syntax is a programming pain
and in this case I really can't see it happening,
particularly as this one is not, as I understand it,
common regular expression syntax.

Nick
[email protected]

[email protected]

Thanks for the response, but houseinc* would include houseinc_mean and I
just want houseinc1-houseinc100.

Like I said, I don't think it is possible, but it would be nice if it were included.

I often find myself renaming variables to get round this - ie I'd rename
houseinc_mean to mean_houseinc then use houseinc* as you suggested. I
simply thought that it would be easy to add something to they varlist
syntax to enable the expansion of just vars ending in a number. But
possibly I'm the only person who would like this.

Mathew



------------------------------

Date: Wed, 10 Jan 2007 13:41:31 -0000
From: "Nick Cox" <[email protected]>
Subject: st: RE: syntax - expanding vars ending in a number

houseinc* is the wildcard you want. This
is documented at [U] 11.4 and the help for varlist.

Nick
[email protected]

[email protected]

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





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

--------------------------------------------------------------------------------

Next Article (by Date): Re: st: xtlogit and constant term [email protected]
Previous Article (by Date): st: RE x: -oneway- and unequal variances "Thomas Erdmann"
Articles sorted by: [Date] [Author] [Subject]


--------------------------------------------------------------------------------

Go to Harvard School of Public Health LWGate Home Page.

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