Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

st: changing formatting of values stored in r()


From   Leslie Liang <G.L.Liang@warwick.ac.uk>
To   statalist@hsphsun2.harvard.edu
Subject   st: changing formatting of values stored in r()
Date   Wed, 14 Apr 2010 11:16:56 +0100

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
g.l.liang@warwick.ac.uk
*
*   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   |   Site index