<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: fixed categories in legend in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/fixed-categories-in-legend/m-p/69979#M2448</link>
    <description>In situations with discrete values, I'd recommend specifying the values you want in the legend via the "midpoints=" in gmap.  But in this case where you have "ranges" of values that are being mapped into discrete bins using user-defined formats, I'm not sure that's possible.&lt;BR /&gt;
&lt;BR /&gt;
But a sure-fire way to get what you're wanting is to insert "fake" values into the data - 1 value in each of the possible ranges.  And by "fake", I mean assign them to a map area that doesn't actually exist in the geographical map (I like to use a map id of '.' (missing)).&lt;BR /&gt;
&lt;BR /&gt;
Here is an example - the first map's data doesn't cover all the ranges in the user-defined format, and the 2nd map (with the addition of 'fake' data) does...&lt;BR /&gt;
&lt;BR /&gt;
proc format;&lt;BR /&gt;
value color&lt;BR /&gt;
	0 = "No Patients"&lt;BR /&gt;
	1-5  = "1-5 Patients" &lt;BR /&gt;
	6-10 = "6-10 Patients" &lt;BR /&gt;
	11-20 = "11-20 Patients" &lt;BR /&gt;
	21-high = "&amp;gt;20  Patients" &lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
pattern1 v=ms c=white;&lt;BR /&gt;
pattern2 v=ms c=grayca;&lt;BR /&gt;
pattern3 v=ms c=yellow;&lt;BR /&gt;
pattern4 v=ms c=orange;&lt;BR /&gt;
pattern5 v=ms c=red;&lt;BR /&gt;
legend1 label=none across=1 position=(right middle);&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
create table real_data as select unique state, (round(ranuni(335)*50))+5 as my_value&lt;BR /&gt;
from maps.us;&lt;BR /&gt;
quit; run;&lt;BR /&gt;
&lt;BR /&gt;
title "Data doesn't cover all possible ranges";&lt;BR /&gt;
proc gmap data=real_data map=maps.us;&lt;BR /&gt;
format my_value color.;&lt;BR /&gt;
id state;&lt;BR /&gt;
choro my_value / discrete legend=legend1;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data fake_data;&lt;BR /&gt;
state=.;&lt;BR /&gt;
my_value=0; output;&lt;BR /&gt;
my_value=1; output;&lt;BR /&gt;
my_value=6; output;&lt;BR /&gt;
my_value=11; output;&lt;BR /&gt;
my_value=21; output;&lt;BR /&gt;
run;&lt;BR /&gt;
data mod_data; set real_data fake_data;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
title "Modified data covers all possible ranges";&lt;BR /&gt;
proc gmap data=mod_data map=maps.us;&lt;BR /&gt;
format my_value color.;&lt;BR /&gt;
id state;&lt;BR /&gt;
choro my_value / discrete legend=legend1;&lt;BR /&gt;
run;</description>
    <pubDate>Tue, 23 Mar 2010 13:54:58 GMT</pubDate>
    <dc:creator>GraphGuy</dc:creator>
    <dc:date>2010-03-23T13:54:58Z</dc:date>
    <item>
      <title>fixed categories in legend</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/fixed-categories-in-legend/m-p/69978#M2447</link>
      <description>Hi -&lt;BR /&gt;
&lt;BR /&gt;
I have a question on legend and pattern with PROC GMAP.  Below is my code.&lt;BR /&gt;
&lt;BR /&gt;
**************************************&lt;BR /&gt;
proc format;&lt;BR /&gt;
value color&lt;BR /&gt;
	0 = "No Patients"&lt;BR /&gt;
	1-5  = "1-5 Patients" &lt;BR /&gt;
	6-10 = "6-10 Patients" &lt;BR /&gt;
	11-20 = "11-20 Patients" &lt;BR /&gt;
	21-high = "&amp;gt;20  Patients" &lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
legend1 origin=(2,70)pct mode=share across=1 shape=bar(2,2) value=(height=1.5);&lt;BR /&gt;
&lt;BR /&gt;
pattern1 v=ms c=white;&lt;BR /&gt;
pattern2 v=ms c=grayca;&lt;BR /&gt;
pattern3 v=ms c=yellow;&lt;BR /&gt;
pattern4 v=ms c=orange;&lt;BR /&gt;
pattern5 v=ms c=red;&lt;BR /&gt;
&lt;BR /&gt;
proc gmap map=edmap.nys_zip_utm data=d&amp;amp;datarange all annotate=countyline;&lt;BR /&gt;
id zip;&lt;BR /&gt;
choro sum&amp;amp;i /discrete legend=legend1 coutline=black cempty=black;&lt;BR /&gt;
format sum&amp;amp;i color.;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
**************************************************&lt;BR /&gt;
&lt;BR /&gt;
Ideally, the map shows 5 colors (using defined 5 patterns) and the legend shows 5 categories. Hower, the problem is that whenever the dataset does not have the value for a category in "sum&amp;amp;i" (e.g., variable "sum&amp;amp;i" contains no values of 0) , the legend will only show 4 categories instead of 5, and the colors will also be wrong (e.g., category "1-5 Patients" will then be mapped white instead of grayca). &lt;BR /&gt;
&lt;BR /&gt;
Does anybody know how to show all categories in the legend even if the data set does not have all category values? Thanks!</description>
      <pubDate>Mon, 22 Mar 2010 17:59:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/fixed-categories-in-legend/m-p/69978#M2447</guid>
      <dc:creator>CharleneW</dc:creator>
      <dc:date>2010-03-22T17:59:23Z</dc:date>
    </item>
    <item>
      <title>Re: fixed categories in legend</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/fixed-categories-in-legend/m-p/69979#M2448</link>
      <description>In situations with discrete values, I'd recommend specifying the values you want in the legend via the "midpoints=" in gmap.  But in this case where you have "ranges" of values that are being mapped into discrete bins using user-defined formats, I'm not sure that's possible.&lt;BR /&gt;
&lt;BR /&gt;
But a sure-fire way to get what you're wanting is to insert "fake" values into the data - 1 value in each of the possible ranges.  And by "fake", I mean assign them to a map area that doesn't actually exist in the geographical map (I like to use a map id of '.' (missing)).&lt;BR /&gt;
&lt;BR /&gt;
Here is an example - the first map's data doesn't cover all the ranges in the user-defined format, and the 2nd map (with the addition of 'fake' data) does...&lt;BR /&gt;
&lt;BR /&gt;
proc format;&lt;BR /&gt;
value color&lt;BR /&gt;
	0 = "No Patients"&lt;BR /&gt;
	1-5  = "1-5 Patients" &lt;BR /&gt;
	6-10 = "6-10 Patients" &lt;BR /&gt;
	11-20 = "11-20 Patients" &lt;BR /&gt;
	21-high = "&amp;gt;20  Patients" &lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
pattern1 v=ms c=white;&lt;BR /&gt;
pattern2 v=ms c=grayca;&lt;BR /&gt;
pattern3 v=ms c=yellow;&lt;BR /&gt;
pattern4 v=ms c=orange;&lt;BR /&gt;
pattern5 v=ms c=red;&lt;BR /&gt;
legend1 label=none across=1 position=(right middle);&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
create table real_data as select unique state, (round(ranuni(335)*50))+5 as my_value&lt;BR /&gt;
from maps.us;&lt;BR /&gt;
quit; run;&lt;BR /&gt;
&lt;BR /&gt;
title "Data doesn't cover all possible ranges";&lt;BR /&gt;
proc gmap data=real_data map=maps.us;&lt;BR /&gt;
format my_value color.;&lt;BR /&gt;
id state;&lt;BR /&gt;
choro my_value / discrete legend=legend1;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data fake_data;&lt;BR /&gt;
state=.;&lt;BR /&gt;
my_value=0; output;&lt;BR /&gt;
my_value=1; output;&lt;BR /&gt;
my_value=6; output;&lt;BR /&gt;
my_value=11; output;&lt;BR /&gt;
my_value=21; output;&lt;BR /&gt;
run;&lt;BR /&gt;
data mod_data; set real_data fake_data;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
title "Modified data covers all possible ranges";&lt;BR /&gt;
proc gmap data=mod_data map=maps.us;&lt;BR /&gt;
format my_value color.;&lt;BR /&gt;
id state;&lt;BR /&gt;
choro my_value / discrete legend=legend1;&lt;BR /&gt;
run;</description>
      <pubDate>Tue, 23 Mar 2010 13:54:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/fixed-categories-in-legend/m-p/69979#M2448</guid>
      <dc:creator>GraphGuy</dc:creator>
      <dc:date>2010-03-23T13:54:58Z</dc:date>
    </item>
    <item>
      <title>Re: fixed categories in legend</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/fixed-categories-in-legend/m-p/69980#M2449</link>
      <description>Thanks Robert! It worked!</description>
      <pubDate>Tue, 23 Mar 2010 14:29:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/fixed-categories-in-legend/m-p/69980#M2449</guid>
      <dc:creator>CharleneW</dc:creator>
      <dc:date>2010-03-23T14:29:35Z</dc:date>
    </item>
  </channel>
</rss>

