Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Michael Stewart <michaelstewartresearch@gmail.com> |
To | statalist@hsphsun2.harvard.edu |
Subject | Re: st: Re: referring to groups of variables by suffixes |
Date | Wed, 28 Nov 2012 11:34:59 -0500 |
Thank you very much nick and steve MIke On Wed, Nov 28, 2012 at 8:09 AM, Nick Cox <njcoxstata@gmail.com> wrote: > 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. > > Nick > > On Wed, Nov 28, 2012 at 1:06 PM, Steve Nakoneshny <scnakone@ucalgary.ca> 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" <michaelstewartresearch@gmail.com> 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: > * http://www.stata.com/help.cgi?search > * http://www.stata.com/support/faqs/resources/statalist-faq/ > * http://www.ats.ucla.edu/stat/stata/ -- Thank you , Yours Sincerely, Mike. * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/