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]

st: RE: RE: Tab gen names


From   "David Radwin" <[email protected]>
To   <[email protected]>
Subject   st: RE: RE: Tab gen names
Date   Mon, 4 Jun 2012 09:32:16 -0700 (PDT)

Oops, sorry, I meant the third line, and the program should be this:

levelsof myvariable
foreach value in `r(levels)' {
	gen `: label (myvariable) `value'' = myvariable == `value'
	}

David
--
David Radwin
Senior Research Associate
MPR Associates, Inc.
2150 Shattuck Ave., Suite 800
Berkeley, CA 94704
Phone: 510-849-4942
Fax: 510-849-0794

www.mprinc.com


> -----Original Message-----
> From: [email protected] [mailto:owner-
> [email protected]] On Behalf Of David Radwin
> Sent: Monday, June 04, 2012 9:24 AM
> To: [email protected]
> Subject: st: RE: Tab gen names
> 
> I would just program this using extended macro functions. For example:
> 
> levelsof myvariable
> foreach value in `r(levels)' {
> 	gen `: label (myvariable) `value'' = myvariable == 1
> 	}
> 
> If you prefer lower case variables as many users do, change the second
> line to
> 
> 	gen `=lower("`: label (myvariable) `value''")' = myvariable == 1
> 
> David
> --
> David Radwin
> Senior Research Associate
> MPR Associates, Inc.
> 2150 Shattuck Ave., Suite 800
> Berkeley, CA 94704
> Phone: 510-849-4942
> Fax: 510-849-0794
> 
> www.mprinc.com
> 
> 
> > -----Original Message-----
> > From: [email protected] [mailto:owner-
> > [email protected]] On Behalf Of Michael Betz
> > Sent: Monday, June 04, 2012 9:15 AM
> > To: [email protected]
> > Subject: st: Tab gen names
> >
> > Hi all,
> >
> > Is there a way to name the variables created by tabulate generate()
> > according to the tabulated variable's value labels. I want to create
> > dummies for each category in the variable "tenure", which takes the
> values
> >
> > 1==Freehold
> > 2==Leasehold
> > 3==Mailo
> > 4==Customary
> >
> > These show up as the newly created variables' labels, but I'd like
them
> to
> > be the variable names. Any thoughts?
> 
> *
> *   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/


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