Data visualization with SAS programming

How to supress labels when using anno in Proc Gmap with a By statement

Accepted Solution Solved
Reply
New Contributor Ray
New Contributor
Posts: 3
Accepted Solution

How to supress labels when using anno in Proc Gmap with a By statement

I have a statewide set of data that I use to produce maps.  I need to label the towns on a map of each county.  The maps come out fine but the labels from towns surrounding each county show up outside of the county area.


Here is how I create the dataset for the labels:

%annomac;

%maplabel (UseMe, UseMe, Labels2use, name, sd_b county,

          font=Arial Black, color=black, size=.8, hsys=3);

run;


'sd_b' is the identifying field for each town and 'county' is the name of the county it is in.  I added county to the list of variables hoping that it would supress the lables not in the county being created but it didn't help.


To create the county maps I use this:

proc gmap

map=work.UseMe

data=work.UseMe

annotate=Labels2use;

by county;

id sd_b;

choro count/

uniform;

run;

quit;

How do I get the procedure to only print the names of the towns that are in the county that is currently being produced instead of all the names that fit in the plot area?


Accepted Solutions
Solution
‎02-23-2012 03:43 PM
New Contributor Ray
New Contributor
Posts: 3

How to supress labels when using anno in Proc Gmap with a By statement

I figured it out!  I had the Annotate statement in the wrong place.

These statements work and only display the names of the towns for the county being produced.


%annomac;
%maplabel (useme, useme, Labels2use, name, sd_b county,
          font=Arial Black, color=black, size=.8, hsys=3);
run;

*MAKE COUNTY MAP;
data useme; set useme;
proc sort; by county;
run;

data labels2use; set labels2use;
proc sort; by county;
run;


proc gmap
map=work.UseMe
data=work.useme;
by county;
id sd_b;
choro count/
annotate=labels2use
uniform;
run;
quit;

View solution in original post


All Replies
Esteemed Advisor
Posts: 7,293

How to supress labels when using anno in Proc Gmap with a By statement

I would think that adding country as a segment variable would have the exact opposite effect of what you are trying to do.  Did you run it with only supplying sd_b as the id variable in the macro?

http://support.sas.com/documentation/cdl/en/graphref/63022/HTML/default/viewer.htm#a002362924.htm

New Contributor Ray
New Contributor
Posts: 3

How to supress labels when using anno in Proc Gmap with a By statement

I tried running the maplabel macro with and without county and it makes no difference.

I found this in the online help which leads me to believe I need to move the annotate option but I'm not sure where to put it.

Using the BY Statement with the Annotate Facility

If a procedure that is using BY-group processing also specifies annotation with the ANNOTATE= option in the PROC statement, the same annotation is applied to every graph generated by the procedure.

If you specify annotation with the ANNOTATE= option in the action statements for a procedure, the BY-group processing is applied to the Annotate data set. In this way, you can customize the annotation for the output from each BY group by including the BY variable in the Annotate data set and by using each BY-variable value as a condition for the annotation to be applied to the output for that value.

Solution
‎02-23-2012 03:43 PM
New Contributor Ray
New Contributor
Posts: 3

How to supress labels when using anno in Proc Gmap with a By statement

I figured it out!  I had the Annotate statement in the wrong place.

These statements work and only display the names of the towns for the county being produced.


%annomac;
%maplabel (useme, useme, Labels2use, name, sd_b county,
          font=Arial Black, color=black, size=.8, hsys=3);
run;

*MAKE COUNTY MAP;
data useme; set useme;
proc sort; by county;
run;

data labels2use; set labels2use;
proc sort; by county;
run;


proc gmap
map=work.UseMe
data=work.useme;
by county;
id sd_b;
choro count/
annotate=labels2use
uniform;
run;
quit;

SAS Employee
Posts: 967

How to supress labels when using anno in Proc Gmap with a By statement

Good job on your self-help, Ray! :-)

Note that this is a very powerful feature of annotate -- it allows you to specify annotations in a way that the 'by' group subsetting will be applied (such as what you were wanting), or annotations that will appear in all the by group graphs ... or both!

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 231 views
  • 0 likes
  • 3 in conversation