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   "Radwin, David" <[email protected]>
To   <[email protected]>
Subject   RE: st: adding variable name to value label
Date   Thu, 26 Sep 2013 13:01:37 -0400

Lin,

You could write a short program using extended macro functions like this:

sysuse voter, clear
codebook

ds, has(varlabel)
foreach v in `r(varlist)' {
	levelsof `v', local(levs)
	foreach l of local levs {
		label define `:value label `v'' `l' `"`:var lab `v''-`:lab (`v') `l''"', modify
		}
	}
	
codebook


David
--
David Radwin
Senior Research Associate
Education Studies Division
RTI International
2150 Shattuck Ave., Suite 800
Berkeley, CA 94704
Phone: 510-665-8274

www.rti.org

> -----Original Message-----
> From: [email protected] [mailto:owner-
> [email protected]] On Behalf Of Song, Lin
> Sent: Thursday, September 26, 2013 9:47 AM
> 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:owner-
> [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,
> 
> From -h label-:
> 
>  Define value label
> 
>         label define lblname # "label" [# "label" ...] [, add modify
> replace nofix]
> 
> The -modify- option should be what you're after.
> 
> Steve
> 
> 
> On 2013-09-26, at 10:37 AM, Song, Lin wrote:
> 
> > Hi Stata users:
> >
> > I'd like to add variable names to value labels.  For example, I have the
> following variables:
> >
> > Q1: 1=yes, 2=no
> > Q2: 1=male, 2=female
> >
> > I'd like to convert the value labels to something like below:
> >
> > Q1: 1="Q1-yes" 2="Q1-no"
> > Q2: 1="Q2-male" 2 "Q2-female"
> >
> > This is for matching two files generated by tabout.  Because of zero
> count for certain values, the two files cannot be matched sequentially.
> >
> > Is there a simple way to do this?
> >
> > Thanks a lot.
> >
> > Lin
> > Lin Song
> > Epidemiologist
> > Public Health - Seattle & King County
> > (206) 263-8773


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