Statalist The Stata Listserver


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

Re: st: varlist error? or feature?


From   David Kantor <kantor.d@att.net>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: varlist error? or feature?
Date   Tue, 17 Oct 2006 16:10:49 -0400

At 03:33 PM 10/17/2006, Jeph Herrin wrote:
Why have I never noticed this before? Stata 9, updated.

. d com1-com45

              storage  display     value
variable name   type   format      label      variable label
-------------------------------------------------------------------------------
com1            byte   %8.0g                  BPH
medcom2         byte   %9.0g                  meds: CA
com2            byte   %8.0g                  CA
medcom3         byte   %9.0g                  meds: CHF/HTN
com3            byte   %8.0g                  CHF/HTN
medcom4         byte   %9.0g                  meds: ESRD
com4            byte   %8.0g                  ESRD
medcom5         byte   %9.0g                  meds: GERD
com5            byte   %8.0g                  GERD
medcom6         byte   %9.0g                  meds: HIV
com6            byte   %8.0g                  HIV
medcom7         byte   %9.0g                  meds: HTN
.
.
.


And I discovered it when

. egen total=rtotal(com1-com45)

totalled all the -medcom- variables as well. How can I reference
just those variables that start with -com-?


thanks,
Jeph
[...]
It should be pointed out that the abbreviation
com1-com45
refers to all variables in the span from com1 to com45, in the set of variables in their present order (which you can change with -order- or -aorder-). It has nothing to do with imputing names that fit the paradigm that you might be supposing. It has always worked that way.

As some other respondents mentioned, what you probably want is com* -- as long as that covers only the variables you want. If you have any names such as "common" or "complete" or "compensation", they will also be picked up by com*. That's why I usually avoid both of these abbreviation forms. Instead, I use a list that contains the exact names I want. If is long, I put it in a macro; sometimes it can be assembled programmatically.

HTH
--David

*
* 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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index