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 at the end of May, and its replacement, statalist.org is already up and running.


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

RE: st: age: factor variables may not contain noninteger values


From   Nick Cox <n.j.cox@durham.ac.uk>
To   "'statalist@hsphsun2.harvard.edu'" <statalist@hsphsun2.harvard.edu>
Subject   RE: st: age: factor variables may not contain noninteger values
Date   Wed, 9 Nov 2011 13:03:53 +0000

I think that we are all partly joking now, but this doesn't convince. [40, 41) is just as much an interval as [39.5, 40.5). 

Nick 
n.j.cox@durham.ac.uk 

Jesper Lindhardsen

I agree with both of you. However, since Lars wanted to use age as a categorical variable , this implies reducing the age information to an interval. In this sense, round will provide the -.5 to +.5 interval..... which makes Lars 40 already ;-)

Nick Cox

All that said, as age as an integer usually means "age last birthday",
I am surprised that -round()- is regarded as the answer. I would put
my foot down for -floor()-.

For example, I am 19 and will not be 20 until next birthday.

Nick

On Tue, Nov 8, 2011 at 7:29 PM, Lars Folkestad <lfolkestad@health.sdu.dk> wrote:
> Thank you for that jesper. It sure did the trick.
> lars
>
> Den 08/11/11 13.17 skrev "Jesper Lindhardsen" <JESLIN01@geh.regionh.dk>:
>
>>Hi Lars,
>>
>>Try
>>
>>
>>g new_age= round(age_var,1)
>>
>>
>>HTH,
>>
>>Jesper
>>
>>-----Original Message-----
>>From: owner-statalist@hsphsun2.harvard.edu
>>[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Lars
>>Folkestad
>>Sent: 08 November 2011 12:14
>>To: statalist@hsphsun2.harvard.edu
>>Subject: Re: st: age: factor variables may not contain noninteger values
>>
>>This helps a lot.
>>Thank you.
>>
>>But i have a question about the second point.
>>Is there a quick and easy way to round the age to the nearest integer
>>value? I could use the floor / ceil functions, but some of the ages
>>Should be rounded up and some should be rounded down.
>>

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index