Statalist


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

Re: st: RE: -encode- help..


From   "Sergiy Radyakin" <[email protected]>
To   [email protected]
Subject   Re: st: RE: -encode- help..
Date   Wed, 19 Nov 2008 18:08:13 -0500

So how can you guarantee that non-event will get the 0 code? The codes
will be assigned in alphabetical order of the strings.

If you have only two values, than it's even easier, don't use
-recode-, but a -generate-:

label define lab_event 1 "event" 0 "non-event"
forvalues i=1/30 {
  generate stub`i'_n=(stub`i'_str=="event") if stub`i'_str!=""
  label values stub`i'_n lab_event
}

Regards,
   Sergiy


On Wed, Nov 19, 2008 at 5:49 PM, moleps islon <[email protected]> wrote:
> The zero start is just for an old habit whereby I'm used to code
> events/non-events 1/0..Easy work around, but I cant get rid of old
> habits..
>
>
>
> On Wed, Nov 19, 2008 at 10:27 PM, Nick Cox <[email protected]> wrote:
>> You can do it, but not I think directly. Here is one way:
>>
>> sysuse auto
>> egen nmake = group(make)
>> replace nmake = nmake - 1
>> labmask nmake, values(make)
>>
>> where -labmask- should be located using -findit-.
>>
>> But I can't see that zero-start has any real advantages. Can you name
>> any?
>>
>> Nick
>> [email protected]
>>
>> moleps islon
>>
>> is it possible, somehow, to
>> specify stata to start encoding with tha value 0 instead of 1 ?
>>
>>
>> *
>> *   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/
>
*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index