BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
P5C768
Obsidian | Level 7

I am trying to map some street addresses and have them show up as icons (stars) using the maps.us table as my mapping table and the annotate process.  I've found some great examples of what I want to do online:

SAS/GRAPH(R) 9.2: Reference, Second Edition

http://www.nesug.org/proceedings/nesug08/np/np05.pdf

However, I can't seem to get my locations to show up.  Here is my process:

proc geocode

   method=STREET

   data=temp

   out=GEOCODED

   lookupstreet=SASHELP.GEOEXM

   attributevar=(TRACTCE00);

run;

data anno;

  set GEOCODED;

  length function style color text $8;

  format X Y comma12.10;

  xsys='2';

  ysys='2';

  hsys='3';

  when='A';

  function = 'label';

  style='special';

  text='M';

  color='Red';

  size=5;

  position='E';

  segment=1;

  x=atan(1)/45 * x;

  y=atan(1)/45 * y * -1;

run;

proc gproject data=anno out=annop;

  id segment;

run;

proc gmap

  map=maps.us

  data=maps.us

  anno=annop;

  id statecode;

  choro statecode / nolegend;

  where statecode not in ("AK", "HI", "PR");

run;

quit;

I think the problem has something to do with the radians/degrees conversion, but I'm not sure if I need to have my map set and annotate set in the same table.  Any help is appreciated.  Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
GraphGuy
Meteorite | Level 14

Here's one example that uses Proc Geocode to look up lat/long, and then plots the results on a U.S. state map:

http://robslink.com/SAS/democd61/meningitis.htm

http://robslink.com/SAS/democd61/meningitis_info.htm

Note that it only looks up the address based on the zipcode (rather than street address) -- this is usually quicker, and depending on what you're plotting, zipcode centroids are usually adequate when plotting on a U.S. state map (of course, you could also use street-level geocoding with this code if you want!)

View solution in original post

4 REPLIES 4
GraphGuy
Meteorite | Level 14

In order to plot lat/long values on a map, you'll need to gproject those coordinates the exact same way the map was projected.  The way that you will see in most examples is to start with an unprojected map, combine the annotate & map, project them both at the same time, and then separate them again.  Before you combine the map and the annotate, you'll want to make sure their x/y (long/lat) are in the same units (degrees or radians, eastlong or westlong).

Note that maps.us is already projected (and doesn't contain unprojected coordinates), and therefore cannot be used with this technique.

I'd recommend you start with a working example, and then modify that to use your data.

GraphGuy
Meteorite | Level 14

Here's one example that uses Proc Geocode to look up lat/long, and then plots the results on a U.S. state map:

http://robslink.com/SAS/democd61/meningitis.htm

http://robslink.com/SAS/democd61/meningitis_info.htm

Note that it only looks up the address based on the zipcode (rather than street address) -- this is usually quicker, and depending on what you're plotting, zipcode centroids are usually adequate when plotting on a U.S. state map (of course, you could also use street-level geocoding with this code if you want!)

P5C768
Obsidian | Level 7

Thanks Robert, as always that was a big help!

BenthamLEE
Calcite | Level 5

The concept of mapping some street addresses and have them show up as icons (stars) using the maps.us table and annotate processing is similar with adding annotation to document page or image within a document image annotation application. You can first save and store you map in any supportable image or document form, like jpeg, png, gif, tiff or pdf, and then embed and load your map into the annotation project to highlight and note and underline the necessary streets addresses.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 1457 views
  • 3 likes
  • 3 in conversation