Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Formatting local variables


From   Maarten buis <maartenbuis@yahoo.co.uk>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Formatting local variables
Date   Thu, 28 Aug 2008 07:52:25 +0100 (BST)

--- Ashim Kapoor <ashimkapoor@gmail.com> wrote:
> I meant a local Macro.
> 
> if I say
> 
> local m=3.123442
> 
> how do I say format %6.2f m and get the right result.

That depends on what you mean by right result. You have to make a
distinction between what Stata has in memory and what Stata shows you:
-format- is only about how Stata displays a variable on screen, no on
how it saves the values. On the other hand the function -round- change
the value that is being stored.

If you want to loose the digits 3442 than type:
local m = round(3.123442, .01)

If you want to keep the number (which is very very much prefered if you
are also using it in computations) than you can type the following:

local m = 3.123442
di %6.2f `m'

-- Maarten

-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------

Send instant messages to your online friends http://uk.messenger.yahoo.com 
*
*   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   |   What's new   |   Site index