Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

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

Re: st: Re: referring to groups of variables by suffixes

From   Nick Cox <>
Subject   Re: st: Re: referring to groups of variables by suffixes
Date   Wed, 28 Nov 2012 13:09:57 +0000

This is undoubtedly good advice. It is one of the reasons I used (the
equivalent of)

ds *_foo

in my own post. Then you can see what your wildcard has caught.


On Wed, Nov 28, 2012 at 1:06 PM, Steve Nakoneshny <> wrote:
> Mike,
> All you need is to use the wildcard as a prefix.
> drop *_foo
> drop *_bar
> This will -drop- all vars with _foo or _bar as terminal. If it so happened that you wanted to drop a var or series of vars with _foo in the middle, you would need to add another wildcard to the end of the -drop- command:
> drop *_foo*
> Be very careful using this technique as it is indiscriminate and you may end up dropping vars unintentionally because of a shared nomenclature.
> Steve
> Sent via carrier pigeon
> On 2012-11-28, at 5:49 AM, "Michael Stewart" <> wrote:
>> Dear Statalist reader,
>> I am working with a large dataset (approx 600 variables) with
>> different names but some of them end in similar manner
>> Eg:
>> procedure__11_procedure_code___i
>> procedure__11_procedure_date
>> procedure__11_procedure_or_ind
>> procedure__11_procedure_tissue_t
>> procedure__11_procedure_type
>> procedure__12_procedure_abnormal
>> procedure__12_procedure_code_icd
>> procedure__12_procedure_date
>> procedure__12_procedure_ep_no
>> procedure__12_procedure_location
>> procedure__12_procedure_or_ind
>> procedure__12_procedure_physicia
>> procedure__12_procedure_tissue_t
>> procedure__12_procedure_type
>> procedure__12_procedure_type0
>> procedure__13_procedure_abnormal
>> procedure__13_procedure_anes_age
>> procedure__13_procedure_anes_met
>> procedure__13_procedure_code_icd
>> procedure__13_procedure_date
>> I want to drop variables ending with procedure_tissue_t and
>> procedure_anes_age. Its tedious to do it for large number of
>> variables.Can you please suggest a shortcut . Is there  a shortcut to
>> refer to all variables ending with procedure_tissue_t &
>> procedure_anes_age.I found shortcuts to refer to variables for
>> prefixes  but not for suffixes so far.
*   For searches and help try:

© Copyright 1996–2016 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index