Statalist


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

Re: st: Formatting local variables


From   "Ashim Kapoor" <[email protected]>
To   [email protected]
Subject   Re: st: Formatting local variables
Date   Thu, 28 Aug 2008 11:41:46 +0530

I meant a local variable. So it is a string I guess. So I can't
specify the decimal precision in output ?

What is a temporary variable  ?

Thank you,
Ashim.

On Thu, Aug 28, 2008 at 11:36 AM, Maarten buis <[email protected]> wrote:
> --- Ashim Kapoor <[email protected]> wrote:
>> I have small query. Do the formats for printing to screen  / writing
>> to a file apply to local variables as well ? I don't think so as my
>> experience tells me otherwise.
>>
>> Is there a way of formatting the ouput of a local variable? any
>> suggestions ?
>
> Do you mean a temporary variable or a local? A local is a string, so if
> you want to format it, than you will have to put the formatted value in
> the local (and usually loose quite a bit of precision) or control the
> output using -display-. A temporary variable is just a variable so you
> can -format- it as any other variable.
>
> *----------------- begin example --------------------
> set obs 1
> // temporary variable
> tempvar bla
> gen `bla' = 1.000001
> di `bla'
>
> // or you can directly -format-
> // the temporary variable
> di %9.3f `bla'
> tab `bla'
> format `bla' %9.3f
> tab `bla'
>
> // local
> local blup 2.0000002
> di `blup'
> di %9.3f `blup'
> *------------------- end example ------------------
> (For more on how to use examples I sent to the Statalist, see
> http://home.fsw.vu.nl/m.buis/stata/exampleFAQ.html )
>
> Hope this helps,
> 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/
>
*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index