[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
RE: st: < and > operand in recode
svend, thanks for your illuminating further advice on -recode-.
agree with you though that as an automatic safety measure, a newvar should have been generated with this command to prevent accidental -replace-. having said that since only the data in the memory changed, it might not be a total disaster that it can be if it went awry but as dick said, having an original would also allow one to -tab oldvar newvar- to compare post -recode-.
i was lucky that i followed the [R] recode and generated newvar, otherwise that would have happened to me.
> Subject: Re: st: < and > operand in recode
> Date: Mon, 21 Aug 2006 13:17:46 +0200
> From: SJ@SOCI.AU.DK
> To: email@example.com
> BW wanted to recode a variable:
> <=1 coded 1 (<= i.e. meaning less than or equal to)
> >1 to <=2 coded 2
> >2 to <= 5 coded 3
> >5 to <=10 coded 4
> >10 coded 5
> - and that gave rise to quite a few comments and useful suggestions.
> However, I was surprised by Nick's dislike of -recode- which he wrote
> was not meant to be used for continuous variables. To me, it works
> perfectly, and I find it more transparent than any of the other
> suggestions. For BW's example it is:
> recode x (min/1=1)(1/2=2)(2/5=3)(5/10=4)(10/max=5) , generate(newx)
> If intervals overlap, the first interval specification wins, so if you
> want 1, 2, 5 and 10 in the upper groups, just reverse the sequence:
> recode x (10/max=5)(5/10=4)(2/5=3)(1/2=2)(min/1=1) , generate(newx)
> -recode- also lets you define value labels at once:
> recode x (min/1=1 "(0-1]")(1/2=2 "(1-2]") ... , generate(newx)
> So, my conclusion is that -recode- is VERY good to create grouped
> variables from continuous variables.
> As stated by others, the -generate()- option is extremely important. To
> prevent accidents it might have been wise to require a -replace- option,
> if the user wants to overwrite an existing variable. But that is
> probably too late now.
> Svend Juul
> Institut for Folkesundhed, Afdeling for Epidemiologi
> (Institute of Public Health, Department of Epidemiology)
> Vennelyst Boulevard 6
> DK-8000 Aarhus C, Denmark
> Phone: +45 8942 6090
> Home: +45 8693 7796
> Email: firstname.lastname@example.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/
Try Live.com - your fast, personalized homepage with all the things you care about in one place.
* For searches and help try: