On Mon, Dec 21, 2009 at 2:37 PM, Alex Olssen <[email protected]> wrote:
> Thanks Scott,
>
> I had kind of guessed at this. The count of polygons is exactly what I want - as each polygon represent a very small but complete geographical unit.
>
> I am now wondering whether Stata stores the count number a scalar somewhere? I have run several graphs and it would be far more efficient if I could make reference to a stored scalar in my code for the legend label as opposed to manually adding the count number to each label separately.
>
-spamp- does hold the counts in temporary matrix (`CLASS'), but I
believe you would have to rewrite how it labels the legend to work
with customized legend labels and the legend count.
What I have done in past is something like:
count if ratio >1 & ratio != . & xcoor != .
local count6 = r(N)
count if ratio >.75 & ratio <=1 & xcoor != .
local count5 = r(N)
count if ratio >.5 & ratio <=.75 & xcoor != .
local count4 = r(N)
count if ratio >.25 & ratio <=.5 & xcoor != .
local count3 = r(N)
count if ratio >0 & ratio <=.25 & xcoor != .
local count2 = r(N)
count if ratio ==. & xcoor != .
local count1 = r(N)
spmap ratio using "G:\data\us maps\usmap.dta", id(id)
clmethod(custom) clbreak(0 .25 .5 .75 1 10) ///
legend(label(6 "Greater than 1 (`count6') ")) ///
legend(label(5 "0.75 to 1.00 (`count5') ")) ///
legend(label(4 "0.50 to 0.75 (`count4') ")) ///
legend(label(3 "0.25 to 0.50 (`count3') ")) ///
legend(label(2 "0.00 to 0.25 (`count2') ")) ///
legend(label(1 "No Data (`count1') ")) ///
...
Scott
*
* 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/