Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: encode


From   Nick Winter <[email protected]>
To   [email protected]
Subject   Re: st: encode
Date   Thu, 02 Dec 2004 13:16:58 -0500

This should automate the process suggested by David Airey (using the -make- variable in the auto.dta):

qui levels make , local(vallist)

local n : word count `vallist'
forval i=`n'(-1)1 {
local cval : word `i' of `vallist'
la de mylabel `=`n'-`i'+1' `"`cval'"' , modify
}
encode make, gen(newmake) label(mylabel)

Of course, this could be rolled into a little program if you need to do it for many variables...

--Nick Winter



At 05:33 PM 12/2/2004 +0000, you wrote:

David Airey wrote:


I can work around this question manually, but encode works in ascending
alphabetical order...is there a way to encode in descending
alphabetical order? This is because I want descending order using the
by_option of my graph command.

General solution: define a value label first and force -encode- to use it.

. lab def mysequence 0 "Zimmerman" 1 "Xenakis" 2 "Weill",modify
. encode composer, gen(Composer) lab(mysequence)

This is pretty tedious if you have a lot of categories, though.

--

Ronan M Conroy ([email protected]) Senior Lecturer in Biostatistics Royal College of Surgeons Dublin 2, Ireland +353 1 402 2431 (fax 2764) -------------------- Just say no to drug reps http://www.nofreelunch.org/

*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
--------------------------------------------------------
Nicholas Winter 607.255.8819 t
Assistant Professor 607.255.4530 f
Department of Government [email protected] e
308 White Hall falcon.arts.cornell.edu/nw53 w
Cornell University
Ithaca, NY 14853-4601

*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/




© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index