BookmarkSubscribeRSS Feed
einstein
Quartz | Level 8

I have the addresses (address line, city state, zip) for individuals in 3 states (DC,MD,VA) and trying to create a map that will show the 3 states together and plot each individual so that I can see where most of them are coming from.

 

Is there some code someone can share with me or point me to the right resources to do this?

 

Thanks!

3 REPLIES 3
GraphGuy
Meteorite | Level 14

Here's one way to do it, using Proc Gmap and annotate ...

 

data my_data;
input statecode $ 1-2 value;
state=stfips(statecode);
datalines;
NC 491
SC 352
VA 108
;
run;

data my_map; set maps.us (where=(statecode in ('NC' 'SC' 'VA')));
run;

proc sql noprint;
create table anno_dots as
select unique my_data.*, uscenter.x, uscenter.y
from my_data left join maps.uscenter
on my_data.state=uscenter.state;
quit; run;

%let max_val=500; /* maximum size of data value to scale to */
%let max_area=40; /* size of the maximum dot you want in the map */
data anno_dots; set anno_dots;
length function $8 color $20;
xsys='2'; ysys='2'; hsys='3'; when='a';
function='pie'; rotate=360;
size=sqrt((value/&max_val)*&max_area/3.14);
color='dodgerblue'; style='psolid'; output;
color='gray33'; style='pempty'; output;
run;

pattern1 v=s color=grayf5;

proc gmap data=my_map map=my_map anno=anno_dots;
id statecode;
choro segment / levels=1 nolegend coutline=gray55;
run;

 

dot_map.png

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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