BookmarkSubscribeRSS Feed
MarcTC
Obsidian | Level 7
Below is my code. I don't know where it goes wrong. Two address points don't show up in the graph. Maybe I don't do gproject or annotation correctly. Any help is appreciated.

===============================================
data city1;
city='Milford'; state_cd='DE'; zip=19963; state=10;
output;
city='Hartly'; state_cd='DE'; zip=19953; state=10;
output;
run;

proc geocode zip
addressstatevar=state_cd
data=city1
out=city2;
run;

proc gproject deg
data=city2
out=city3;
id state;
run;

data city_anno;
set city3;
when='A';
xsys='3'; ysys='3';
function='label';
color='cx330099'; size=1.25; text='J';
position='5'; style='special';
run;

data de1;
set maps.states;
if state=10;
run;

title;

proc gproject
data=maps.states
out=de;
id state;
where state=10;
run;

pattern v=e;

proc gmap map = de
anno = city_anno;
id state;
choro state / nolegend;
run;
quit;
4 REPLIES 4
GraphGuy
Meteorite | Level 14
There were several problems, such as...

You can't gproject the map & annotate data sets separately, or they'll both be projected into different/independent x/y min/max.

Need to convert the lat/long degrees to radians, so they are in the same coordinate system as the map.

Need to multiply the long by -1, so it is the same (eastlong/westlong) as the map's longitude.

Need to use the data coordinate system xsys/ysys=2, rather than 3.

I think the following modified code will do what you're wanting:



data city1;
city='Milford'; state_cd='DE'; zip=19963; state=10;
output;
city='Hartly'; state_cd='DE'; zip=19953; state=10;
output;
run;

proc geocode zip
addressstatevar=state_cd
data=city1
out=city2;
run;

data city_anno; set city2;
/* Convert degrees to radians */
x=atan(1)/45 * x * -1;
y=atan(1)/45 * y;

when='A'; xsys='2'; ysys='2'; hsys='3';
function='pie'; color='cx330099'; size=1.5;
style='psolid'; rotate=360;
annoflag=1;
run;

data de;
set maps.states (where=(state=10));
run;

/* combine the map & annotate, gproject them together, then separate them */
data combined; set de city_anno;
proc gproject data=combined out=combined;
id state;
run;
data de city_anno; set combined;
if annoflag=1 then output city_anno;
else output de;
run;

title;
goptions cback=white;
pattern v=s c=white;
proc gmap map=de anno=city_anno;
id state;
choro state / levels=1 nolegend coutline=gray55;
run;
quit;
MarcTC
Obsidian | Level 7
This is really helpful! Thanks, Robert.
MarcTC
Obsidian | Level 7
If I change the size to be 0.5 in data city_anno step, proc gmap doesn't produce a round dot for me.

data city_anno; set city2;
/* Convert degrees to radians */
x=atan(1)/45 * x * -1;
y=atan(1)/45 * y;

when='A'; xsys='2'; ysys='2'; hsys='3';
function='pie'; color='cx330099'; size=0.5;
style='psolid'; rotate=360;
annoflag=1;
run;
GraphGuy
Meteorite | Level 14
Ahh! ... round dots! This topic has gone round & round on the forum lately!
(pun intended! 😉

Depending on what kind of output you can use, you might try some other goptions device= settings, such as pdf or svg. Depending on several factors, you might get dots with smoother more-round edges.

Also, you might try an style='pempty' (outline) rather than style='psolid' - sometimes that makes a difference.

There are also several other tips in a recent thread - I'll let you check them out there, rather than repeat them here.

Also, in the 9.3 version (currently under development), there have been some improvements ... but it will be a while before 9.3 is completed, and available to customers.

This might be a good issue to call-in to Tech Support, so they can document in the official system that this is causing problems. This will help make it more likely to get fixed.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1349 views
  • 0 likes
  • 2 in conversation