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 insert decimal point?


From   Richard Goldstein <[email protected]>
To   [email protected]
Subject   Re: st: How to insert decimal point?
Date   Tue, 23 Aug 2011 15:32:03 -0400

you don't tell us whether this is a number or a string variable; nor do
you tell us what the format is

if it is a number, divide by 100; if you need to change the format, see
-help format-

if it is a string and you want to leave it as a string, try the following:

replace
Claimed_Amount=substr(Claimed_Amount,1,7)+"."+substr(Claimed_Amount,8,2)

but note that this will make it 10 characters long; if you want it to
stay 9 characters, replace the "1" in the first substr() with a "2"
(assuming you won't lose any information that way)

Rich

On 8/23/11 3:21 PM, Lucie Vlach wrote:
> Hello all!
> 
> I have a problem, trying to format my data in my 'Claimed_Amount' variable to say 0000051.61 (not 000005161) and 0000067.31 etc.
> 
> I am trying to insert the decimal point, two spaces from the end, in this numeric variable.
> Each is number is 9 spaces long.
> 
> 000005161 should display 0000051.61
> 
> DATA:
> Claimed_Amount
> 000005161
> 000006731
> 000006666
> 000008890
> 000002256
> 000008301
> 000005161
> 000005161
> 000006731
> 000008890
> 000002256
> 000007449
> 000011889
> 000005879
> 000009019
> 000005161
> etc.
> 
> Thank you all very much for any help!
> 
> Lucie
*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index