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: adding variable name to value label


From   Joe Canner <[email protected]>
To   "[email protected]" <[email protected]>
Subject   RE: st: adding variable name to value label
Date   Thu, 26 Sep 2013 16:57:59 +0000

Lin,

I was going to suggest a solution to do this automatically, but it seems much more complicated than I first thought, depending on how many values each variable has.

For the examples you gave you could do something like:

foreach var of varlist Q* {     // or some other varlist
local labelname : value label `var'
local lab1 : label `labelname' 1
local lab2 : label `labelname' 2
label define `labelname' 1 `var'_'lab1' 2 `var'_`lab2'
label var `var' `labelname', modify
}

If you have more than two values for some variables, this could get more tedious or you will have to loop through the values using -levelsof'.  Let us know if this is the case and we can suggest further refinements.

Regards,
Joe Canner
Johns Hopkins University School of Medicine


-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Song, Lin
Sent: Thursday, September 26, 2013 12:47 PM
To: '[email protected]'
Subject: RE: st: adding variable name to value label

Hi Steve, 

 Thanks for your reply.

Since I have over 100 variables, I was looking for a simple program that can add the variable name to the value label automatically.

Lin

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Steve Nakoneshny
Sent: Thursday, September 26, 2013 9:43 AM
To: [email protected]
Subject: Re: st: adding variable name to value label

Lin,



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