Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: How to drop a repeated word in different label variables
From
Federico Belotti <[email protected]>
To
[email protected]
Subject
Re: st: How to drop a repeated word in different label variables
Date
Fri, 9 Aug 2013 13:13:29 +0200
Sorry. I misread the post.
A possible solution could be
foreach var of varlist x1 x2 x3 {
loc oldlab: var lab `var'
local newlab = subinstr("`oldlab'", "Average Speed ", "", 1)
lab var `var' "`newlab'"
}
Federico
On Aug 9, 2013, at 12:59 PM, Alice Guerra wrote:
> Dear Statalists,
>
> in my dataset, I have different variables whose labels have the same initial words (Average Speed), as follows:
>
> x1 "Average Speed car 1"
> x2 "Average Speed car 2"
> x3 "Average Speed car 3"
>
> I would like to drop "Average Speed" from all the variables labels. The result I would like to reach is as follows:
>
> x1 "car 1"
> x2 "car 2"
> x3 "car 3"
>
> Any suggestion will be very helpful.
>
> Thank you in advance for your time
>
> Alice Guerra
> *
> * 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/
--
Federico Belotti, PhD
Research Fellow
Centre for Economics and International Studies
University of Rome Tor Vergata
tel/fax: +39 06 7259 5627
e-mail: [email protected]
web: http://www.econometrics.it
*
* 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/