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: recoding question


From   "Lachenbruch, Peter" <[email protected]>
To   "[email protected]" <[email protected]>
Subject   RE: st: recoding question
Date   Mon, 24 Dec 2012 19:15:37 +0000

thanks - works well.

Peter A. Lachenbruch,
Professor (retired)
________________________________________
From: [email protected] [[email protected]] on behalf of Richard Goldstein [[email protected]]
Sent: Monday, December 24, 2012 8:18 AM
To: [email protected]
Cc: Lachenbruch, Peter
Subject: Re: st: recoding question

Tony,

I think what you want is the "label" option to the -encode- command;
just be sure to set up the label (using -label define-) before you use
the -encode- command

Rich

On 12/24/12 11:13 AM, Lachenbruch, Peter wrote:
> I have a string variable with codes
> Markedly Improved
> Markedly Worse
> Moderately Improved
> Moderately Worse
> Slightly Improved
> Slightly Worse
> Unchanged
>
> I want to convert these to a numeric variable, but ordered in terms of improvement.  I was looking for a way to do this easily in one step, but didn't find a simple command like encode or recode.  I ended up using encode to get the variables numeric and then recoding them.
> Is there a simple way to do this?   For seven categories it's no big deal, but if I had 20 categories and needed to do this repeatedly, it would be a pain.
> Another option would be to prefix a numeral for the codes but that seems clumsy...
>
>
> Peter A. Lachenbruch,
> Professor (retired)
*
*   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/
*
*   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