a month ago - last edited a month ago
This sounds like an annotate data set is required.
Your requirement will be to determine the x,y coordinates of where everything needs to appear on the map.
Then build a data set.
The SAS supplied macro %annomac should be available if you have GMAP installed. Add this code:
to make all of the other annotate macros available. The log will show how to get descriptions of what the various macros will help you do such as
My first step would be to use the %Maplabel macro to create a data set with the text of the labels and an approximately centered location.
If the text only needs to me moved a bit you can adjust the x and or y coordinates manually in a data step with code like
when(someidvalue) do; x=0.5; y=0.06; end;
when(otheridvalue) x=0.04; /* example of only one coordinate needing adjustment*/
If you actually cannot get a location that will display the text then you need to specify:
1) a location for the actual text label
2) the text to display at that location (these two can be done with a %label macro call.)
3) specify a start location (near the text label) coordinates,
4) end location for an arrow (the %maplabel location likely
5) specify the arrow appearance options (the %arrow macro should work for 3,4,5)
The individual annotate macros such as %arrow should appear in the online documentation as well.
Insert the appropriate macro calls for the id variable in the SELECT block for the ids that need the moved label and the arrow.
Then tell gmap to use the annotate data set. Please be aware the you can use two annotate data sets, one on the Proc Statement and one on a plot statement like CHORO.
If you are likely to have many of these maps it will likely be a good idea to create a permanent data set with the appropriate coordinates to reuse.
4 weeks ago
I wasn't successful with the code. Maybe you could use this datasets on this link to explain it better. Here is the link https://communities.sas.com/t5/SAS-GRAPH-and-ODS-Graphics/using-colors-on-maps-gmap/m-p/457338#M1572...
4 weeks ago
One of my recent blog posts had a map with custom label placement, and arrows pointing from the label to the geographic area. I used lat/long coordinates for both the geographic label, and the area on the map:
Here's a link to the code I used:
3 weeks ago - last edited 3 weeks ago
I have being struggling with your code samples but am not getting through.
This is my code, maybe am doing something wrong but I can't fish it out. Please I need your help again. The labels are for the map on the link https://communities.sas.com/t5/SAS-GRAPH-and-ODS-Graphics/using-colors-on-maps-gmap/m-p/457338#M1572...
Here is the code I have written so far
data anno_drawarrow; length function $8 color $8; set annolabel; flag= 0; xsys='2'; ysys='2'; hsys='3'; when='a'; function='label'; color='black'; size=2.5; if id not in (ab, md, un, cd) then do; text=incidence; position='5'; output; end; else if id in (ab, md, un, cd)then do; text=incidence; position='6'; output; function='move'; text=''; position=''; flag=1;output; end; if flag=1 then do; position=''; text=''; function='draw'; size=.25; flag=0;output; end; run;
here ist the maplabel data.
I want some labels to go outside the map and use arrows to label them