Bookmark and Share

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: Re-labelling multiple variables


From   Sergiy Radyakin <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: Re-labelling multiple variables
Date   Mon, 10 Jun 2013 21:24:30 -0400

sysuse auto, clear
ds
local y=2001
foreach v in `r(varlist)' {
  di "`v'"
  label variable `v' `"grsapechildold`y'"'
  local y=`y'+1
}
describe
*** data preparation done
ds
foreach v in `r(varlist)' {
  local l `"`: variable label `v''"'
  local l=subinstr(`"`l'"',"grsapechildold","Dependency Ratio (%), ",.)
  label variable `v' `"`l'"'
}

describe

Best, Sergiy




On Mon, Jun 10, 2013 at 7:58 PM, Konrad <[email protected]> wrote:
> Dear Statlist readers,
>
> I would like to rename a set of variables by replacing a part of a string in variable label with another string. For instance, I imported a number of variables correponding to dependecy ratios. After the import each variable has a label grsapechildoldYEAR, I would like to replace first word with more meaningful text.
>
> local changvrs grsapechildold2003 - grsapechildold2011
> foreach var of varlist `changvrs' {
>         label `var' regexr(`var', "grsapechildold", "Dependency Ratio (%)")
>         }
>
> I don’t know how to mix string replacement commands with variable labelling. As usual, any help will be appreciated.
>
>
>
> --
> Regards
> Konrad
>
>
> *
> *   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/

*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index