Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: st: Understanding Factor variables - is order significant ?

From   "Feiveson, Alan H. (JSC-SK311)" <>
To   "" <>
Subject   RE: st: Understanding Factor variables - is order significant ?
Date   Thu, 27 May 2010 09:52:19 -0500

Rich - I agree.

OK - How about an "order" option on encode:

encode stringvar,order(Low Medium High)


This would replace doing

label define level 1 "Low" 2 "Medium" 3 "High"
label values stringvar level

(maybe a trivial amount of extra work in this example, but not if you had a list of 20 levels or so and had to list them all  with numbers and double quotes around each one)

Al F.

-----Original Message-----
From: [] On Behalf Of Richard Williams
Sent: Thursday, May 27, 2010 9:44 AM
Subject: RE: st: Understanding Factor variables - is order significant ?

At 10:38 AM 5/27/2010, Feiveson, Alan H. (JSC-SK311) wrote:
>The trouble with -encode- is that it puts the levels in alphabetical 
>order. So in the L, M, H case you would get H = 1, L = 2, M = 3. To 
>get around this you would have to define a label by hand and assign 
>it to the string variable.
>Al F.

True, but as Nick points out you would have the same problem with 
factor variables.  One way or another you have to do a little extra 
work to get the codes in the order you want if they aren't in that 
order already.

Richard Williams, Notre Dame Dept of Sociology
OFFICE: (574)631-6668, (574)631-6463
HOME:   (574)289-5227
EMAIL:  Richard.A.Williams.5@ND.Edu

*   For searches and help try:

*   For searches and help try:

© Copyright 1996–2016 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index