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 rename value label names to match variable names?
From
Tim Wade <[email protected]>
To
[email protected]
Subject
Re: st: How to rename value label names to match variable names?
Date
Sat, 15 May 2010 22:46:27 -0400
I'm not 100% certain what you are asking but if you want to relabel
the newly generated variables so that the labels are the same as the
new variable names, this should work:
sysuse auto.dta, clear
rename make make1
rename price price1
desc make1 price1
foreach var of varlist make1 price1 {
label variable `var' "`var'"
}
desc make1 price1
storage display value
variable name type format label variable label
----------------------------------------------------------------------------------------------------------------------------------------------------------------
make1 str18 %-18s make1
price1 int %8.0gc price1
Tim
On Sat, May 15, 2010 at 10:06 PM, Anna Reimondos <[email protected]> wrote:
> Hello,
> The following problem has me stumped.
> I have a dataset with variables which have been labelled with value
> labels. Currently the variables are names as "a1, a2, a3" etc, and I
> need to rename all my variables so that they are listed as "V1, V2,
> V3" etc. This I can easily do. The problem is that I also need to
> rename all the value label names to match the new variable names.
>
> For example, the current situation is:
>
> varname label name
> ------------------------------
>
> a1 a1
> a2 a2
> a3 yesno
> a4 gender
> ------------------------------
>
> What I need to have is:
>
> varname label name
> ------------------------------
>
> V1 V1
> V2 V2
> V3 V3
> V4 V4
> ------------------------------
>
>
> Does anyone have any suggestions on how I can rename the label names
> to match the variable names? I found a number of similar questions on
> Statalist but most seem to be going the other way (i.e from renaming
> variables to match the label names)
>
> Thanks heaps
> Anna
>
> *
> * 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/