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]

From |
daniel klein <klein.daniel.81@googlemail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: Recode and Label problem |

Date |
Wed, 17 Oct 2012 09:02:03 +0200 |

Malay, I have a bundle of programs -labutil2- (SSC) that deal with value labels. There are several solutions to your problem with those programs (including a recently programmed, but not yet released), but I think in your case you might be just as fast with official Stata commands. First off, note that in your case recode <foo> (2=0) will change the original variable. That is, in most cases not a good idea. I will, however ignore that for now. Note that this does _not_ change any labels whatsoever. I just wanted to point out a faster solution replace <foo> = <foo> - 1 if !mi(<foo>) will give the same binary indicator, but -replace- (or -generate-, if you want a new variable) is much faster than -recode- (might not be a problem in a simple do-file, though). I think a convenient way to solve your problem, is to use one value label, say <yesno>, for all your binary indicator variables. Given you already have all your variables changed to indicators, you type la de yesno 1 yes 0 no la val <firstindicator>-<lastindicator> yesno to do this. If you want to create new variables, using -recode- would be convenient (also Nick Cox might disagree here) recode <firstvartochange>-<lastvartochange> (1 = 1 "yes")(2 = 0 "no") ,pre(b_) l(yesno) Omitting option -label()- will create a value label b_<varname> for each of the new indicator variables. Best Daniel -- Dear All, Thank you for all the supports given to me by some of you in my earlier requests. Sincerely appreciated. I am having one small but nagging problem. I know that I am just one small command away of what I want - but it had alredy consumed quite a bit time. Problem: Good number of variables in my data were coded as 1( Yes) and 2 (No). (Problematic for logistic analysis) So I used the command: recode var39 2=0 (This command changes all my values (2) in the variable39 to 0. But while executing the command, it changes my label too and dsiplay 0. So again I use : label define var39 0 "No" 1 "Yes" It does not change the label in the data from zero to No. In all my analysis it shows Yes as Yes but No to 2. What I want is to code it as zero but label it as No. (var39 is my variable having two options: Yes(1) or No (2)) I am not sure whether I have articulated the problem well. Thank you for your time. With regards Malay * * 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/

- Prev by Date:
**Re: st: Interpreting interactions** - Next by Date:
**Re: st: Recode and Label problem** - Previous by thread:
**st: Recode and Label problem** - Next by thread:
**Re: st: Recode and Label problem** - Index(es):