Bookmark and Share

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

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

st: problem with `r(min)' and `r(mean)' macros

From   mario fiorini <>
Subject   st: problem with `r(min)' and `r(mean)' macros
Date   Mon, 28 Jan 2013 15:47:19 +0100

Dear statalist,
I am summarising a variable and then trying to use the `r(.)' macros
However, in some instances Stata does not seem to find any variables
that take the `r(min)' and `r(mean)' values. For some reason, it does
work with `r(max)' instead.
The code below should clarify the problem. When I run it, I always get
that no observation takes the min or the mean (why???), but there is
an observation that takes the max.
The problem does not depend on whether I use the original `r(min)' or
a macro=`r(min)'.
If it matters I am using a mac osx 10.8 with Stata 12.1 MP.
Any hint would be appreciated because it is driving me crazy.

 // Start
set obs 1000
ge id = _n
ge var1 = uniform()
su var1
local LCmin =`r(min)'
local LCmean =`r(mean)'
local LCmax =`r(max)'

count if var1==`LCmin'
count if var1==`LCmean'
count if var1==`LCmax'
 // Ends
*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index