Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: AW: rounding a tempvar


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: AW: rounding a tempvar
Date   Tue, 23 Jun 2009 18:23:47 +0200

<> 

Use "macro extended functions" as in - help extended_fcn-

*************
clear*
drawnorm x y, n(100) /* 
 */ corr(1,0.71 \ 0.71, 1) /* 
 */ cstorage(full)

corr

di in red `r(rho)'
di in red %3.2fc `r(rho)'

local wcorr: /* 
 */ di %3.2fc `r(rho)'

di `wcorr'
*************



HTH
Martin

-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Cathy L.
Antonakos
Gesendet: Dienstag, 23. Juni 2009 18:18
An: statalist@hsphsun2.harvard.edu
Betreff: st: rounding a tempvar

Dear Statalist,

I want to display a correlation on a graph, rounded to 2 decimal places. A
new, temporary variable, generated as follows, does not produce the rounded
correlation I expect (r = 0.71).

. corr wandurav wanrate
(obs=177)

              | wandurav  wanrate
-------------+------------------
     wandurav |   1.0000
      wanrate |   0.7085   1.0000

. display `r(rho)'
.70846375

. tempvar wcorr

. gen `wcorr' = round(`r(rho)', .01)

. display `wcorr'
.70999998


There must be a simple way to do this. 
Thanks for your help.
Cathy

*
*   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   |   What's new   |   Site index