I am allocating zipcodes to facilities using a proc optmodel. After it is done, I am comparing initial and final maps. How can I make the legends the same color if the proc optmodel is removing some facilities ?
My response data looks like [zip,facility] , eg [12345, ABC].[456789,PQR] and model might tell me [12345,ABC],[456789,ABC] thus shutting down PQR facility.
The only way is to manually list the facilities and assign them a colour (one pattern for each), and then use the second list of facilities to assign the remaining ones the same pattern.
For example
ABC => pattern1=blue
ABD => pattern2=red
ABE => pattern3=green
then
ABC => pattern1=blue
ABE => pattern2=green
Easiest is likely to define a single legend with all of the facilities and use that. Yes, some facilities that are not included will be in the legend. I suggest that having legend items that do not appear in the map may be a way to quickly identify which were removed by the modeling or other processes.
I'm not sure how you'd implement the 2 suggestions provided so far.
But here's what I recommend. Use gmap's "midpoints=" option to list all the things you want in the legend (then they'll appear, even if they aren't in the data in that particular map). Here's a short example showing how to use it:
data foo1;
statecode='NC'; value='ABC'; output;
statecode='SC'; value='PQR'; output;
run;
data foo2;
statecode='NC'; value='ABC'; output;
statecode='SC'; value='ABC'; output;
run;
proc gmap data=foo1 map=maps.us;
id statecode;
choro value / midpoints='ABC' 'PQR';
proc gmap data=foo2 map=maps.us;
id statecode;
choro value / midpoints='ABC' 'PQR';
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.