Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

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

From |
Lucie Vlach <Lucie.Vlach@albertahealthservices.ca> |

To |
"statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |

Subject |
RE: st: How to insert decimal point? |

Date |
Tue, 23 Aug 2011 16:08:56 -0600 |

hello Rich! I tried your command for the string version and it worked! Thank you very much! I also tried to destring that _after_ your command, and it simply removed all zeros, and in some cases the decimal point, if the value was only 1. (original number 000000100) ------------------- . replace Claimed_Amount=substr(Claimed_Amount,1,7)+"."+substr(Claimed_Amount,8,2) Claimed_Amount was str9 now str10 (27819 real changes made) . destring Claimed_Amount, replace Claimed_Amount has all characters numeric; replaced as double ------------------- I think I can live with that, basically in our data, 000005161 got changed to 0000051.61 though the first command and to 51.61 using 'destring' command. To us here it means $51.61 in plain language. Thank you! Lucie -- ________________________________________ From: owner-statalist@hsphsun2.harvard.edu [owner-statalist@hsphsun2.harvard.edu] On Behalf Of Richard Goldstein [richgold@ix.netcom.com] Sent: August 23, 2011 1:32 PM To: statalist@hsphsun2.harvard.edu Subject: Re: st: How to insert decimal point? 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/ This message and any attached documents are only for the use of the intended recipient(s), are confidential and may contain privileged information. Any unauthorized review, use, retransmission, or other disclosure is strictly prohibited. If you have received this message in error, please notify the sender immediately, and then delete the original message. Thank you. * * 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/

**Follow-Ups**:**Re: st: How to insert decimal point?***From:*Nick Cox <njcoxstata@gmail.com>

**References**:**st: How to insert decimal point?***From:*Lucie Vlach <Lucie.Vlach@albertahealthservices.ca>

**Re: st: How to insert decimal point?***From:*Richard Goldstein <richgold@ix.netcom.com>

- Prev by Date:
**Re: st: How to insert decimal point?** - Next by Date:
**Re: st: Recurrent Events and Terminal Event** - Previous by thread:
**Re: st: How to insert decimal point?** - Next by thread:
**Re: st: How to insert decimal point?** - Index(es):