Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: removing decimals


From   Laura Miller <laura.miller@mrc-bsu.cam.ac.uk>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: removing decimals
Date   Thu, 23 Jan 2003 16:08:49 +0000 (GMT)

Thanks

all sorted now

Laura


Envelope-to: laura.miller@mrc-bsu.cam.ac.uk
Delivery-date: Thu, 23 Jan 2003 16:04:52 +0000
X-Authentication-Warning: hsphsun2.harvard.edu: majordom set sender to 
owner-statalist@hsphsun2.harvard.edu using -f
X-Sender: lacop@l.imap.itd.umich.edu
Date: Thu, 23 Jan 2003 11:03:27 -0500
To: statalist@hsphsun2.harvard.edu
From: Laurel A Copeland <lacop@umich.edu>
Subject: Re: st: removing decimals
Mime-Version: 1.0

You can use int()
e.g.,
. gen ageyrs=int(age)

. list

            age     ageyrs
   1.      14.1         14
   2.      12.8         12
   3.      22.3         22
   4.      27.9         27
   5.        30         30
   6.      21.4         21
   7.        14         14
   8.      15.5         15
   9.      11.8         11
  10.      24.7         24

At 03:54 PM 1/23/2003 +0000, you wrote:
>My apologies for bothering you all with such a simple query.
>
>I have calculated a variable which is the age of a subject when they were
>interviewed. However this variable has several decimal places. I wish to 
>change
>this to the whole number of years. I have tried using
>
>format varname %2.0f
>
>but as the manuals state this doesn't affect the accuracy so some of the ages
>are rounding up. I only want complete years so need to round them all down 
>(or
>looking at it another way, I just need to 'cut off' the decimal points). 
>Could
>anyone tell me how can I do this?
>
>
>Any suggestions appreciated.
>
>Laura
>
>***********************************************************************
>MRC Biostatistics Unit                  Tel: 01223 330392
>Institute of Public Health              Fax: 01223 330388
>University Forvie Site                  laura.miller@mrc-bsu.cam.ac.uk
>Robinson Way                            http://www.mrc-bsu.cam.ac.uk
>Cambridge CB2 2SR
>***********************************************************************
>
>
>*
>*   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/

*
*   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/

***********************************************************************
MRC Biostatistics Unit			Tel: 01223 330392
Institute of Public Health		Fax: 01223 330388
University Forvie Site			laura.miller@mrc-bsu.cam.ac.uk
Robinson Way				http://www.mrc-bsu.cam.ac.uk
Cambridge CB2 2SR
***********************************************************************


*
*   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/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index