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