Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

st: AW: changing formatting of values stored in r()


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: AW: changing formatting of values stored in r()
Date   Wed, 14 Apr 2010 13:09:47 +0200

<> 

" I am still able to use -display `string(`r(r1)',`"%9.2f"'- to get the
formatting I desire, but I can't seem to fit it into -lab define-."



Leslie may also want to check out -help extended_fcn-. If you are able to
-display- the way you want, you can put the displayed result into a -macro-,
which often facilitates further processing.

*************
sysuse auto, clear
_pctile mpg, p(5)
local mymacro: display string(`r(r1)',"%9.2f")
di in r "`mymacro'"
*************



HTH
Martin

-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Leslie Liang
Gesendet: Mittwoch, 14. April 2010 12:17
An: [email protected]
Betreff: st: changing formatting of values stored in r()

Hi

I'm trying to label a variable by the values stored in r() but am having
difficulties getting the labels formatted correctly

xtile var2=var1, nq(5)
_pctile var1, nq(5)
ret list
lab define var2 1 "<`r(r1)'" 2 "`r(r1)'<`r(r2)'" 3 "`r(r2)'<`r(r3)'" 4
"`r(r3)'<`r(r4)'" 5 "<`r(r4)'"

I have a new variable, var2, split in 5 quantiles and I would like to label
them based on the the r() returned from -_pctile-. I then proceed to define
the labels as shown above, but the number of dec places are too many. I
would just like them to follow "%9.2f" but i can't seem to specify it
anywhere.

alternatively, I have tried:

lab define var2 1 `"`string(`r(r1)',`"%9.2f"')'"'
invalid attempt to modify label
r(180);

but I keep getting an error. Is there something wrong with my syntax? I am
still able to use -display `string(`r(r1)',`"%9.2f"'- to get the formatting
I desire, but I can't seem to fit it into -lab define-.

Cheers
Leslie
[email protected]
*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index