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]

st: AW: leading zeros with decimals


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: AW: leading zeros with decimals
Date   Thu, 22 Apr 2010 17:44:18 +0200

<> 



*************
di %07.2f 3.2
*************



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Ann Owens
Gesendet: Donnerstag, 22. April 2010 17:41
An: statalist@hsphsun2.harvard.edu
Betreff: st: leading zeros with decimals

Hello,

I have data that need to be formatted with leading zeros and decimal
places. Specifically, I need 4 digits before the decimal and 2 after.
According to the Stata help file for format, I should be able to
achieve this through:

format var %04.2f

However, this does not add leading zeros. It seems like something with
the decimal is throwing it off, because using %04.0f will give me
leading zeros. I've also tried:

gen str7 newvar=string(var, "%04.2f")

with no success (again, no leading zeros). Any suggestions?

Thanks!
Ann
*
*   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/


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