Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Debs Majumdar <debs_stata@yahoo.com> |
To | "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |
Subject | Re: st: Drop variables based on variable label |
Date | Tue, 27 Dec 2011 23:29:49 -0800 (PST) |
I see what are you trying to do but it's not dropping the variables. Thanks, -Joey ----- Original Message ----- From: A Loumiotis <antonis.loumiotis@gmail.com> To: statalist@hsphsun2.harvard.edu Cc: Sent: Tuesday, December 27, 2011 11:07 PM Subject: Re: st: Drop variables based on variable label Hi Joey, You could try this: ds foreach var in `r(varlist)' { if substr("`:var l `var''",1,2)=="rs" drop `var' } Best, Antonis On Wed, Dec 28, 2011 at 7:01 AM, Shubhabrata Mukherjee <joy_stat@yahoo.com> wrote: > Hi All, > > Is there a way to drop variables based on variable label? > > I have some variables (which are redundant) whose variable label start with 'rs'. > > E.g. > > var label > > v1 rs12 > > v2 s13 > > v3 rs14 > v4 rs17 > v5 s15 > ........... > ....... > .... > > I want to drop the variables whose label starts with rs (v1, v3, v4,...). > > Any help is appreciated. > > Thanks, > > -Joey > > * > * For searches and help try: > * http://www.stata.com/help.cgi?search > * http://www.stata.com/support/statalist/faq > * http://www.ats.ucla.edu/stat/stata/ * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/ * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/