Bookmark and Share

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]

Re: st: how to keep number after comma only


From   Nick Cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: how to keep number after comma only
Date   Tue, 25 Feb 2014 16:36:08 +0000

The fractional part is the remainder on division by 1.

. di mod(_pi, 1)
.14159265

. di mod(3.1,1)
.1

or the difference between a number and its floor.

Nick
[email protected]


On 25 February 2014 16:24, Dao Kim <[email protected]> wrote:


I am trying to keep only the digits of a number, for example 37.1
weeks in order to convert it into days. I could keep the first 2
numbers with "gen long term_days = floor(term/10)", how does it work
for the number after the comma?
*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index