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

st: Fixed format question


From   "Bob Fitzgerald" <bfitzgerald@mprinc.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: Fixed format question
Date   Sun, 20 Jun 2010 16:59:08 -0700 (PDT)

Thanks Martin. Exactly what was needed. Much appreciated.

Regards,

Bob

Date: Sat, 19 Jun 2010 20:27:35 +0200
From: "Martin Weiss" <martin.weiss1@gmx.de>
Subject: st: AW: Fixed format question

<>


You probably think in terms of the format in a famous spreadsheet
software. Use Stata`s -round()- function to get what you want:


*************
di %4.1f .015
di %4.2f .015
di %03.2f round(.015,.01)
*************



HTH
Martin


- -----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Bob
Fitzgerald
Gesendet: Samstag, 19. Juni 2010 20:14
An: statalist@hsphsun2.harvard.edu
Betreff: st: Fixed format question

For a report I need to have all numbers rounded and formatted to 2 decimal
places. I expected
that for var1 = .015 formatted to 2 decimal places, .02 would be shown.
However, applying
"format var1 %4.2f" and displaying var1 shows .01.

As an analogue, I tried the following:  var2=.15, to which I applied
"format var2 %4.1".  The
resulting display is ".2".

Any hints about how to achieve my desired result would be much
appreciated.

Many thanks.

Bob

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