Data visualization with SAS programming

US Map

Reply
Frequent Contributor
Posts: 77

US Map

Most of US Map examples generated by SAS/GRAPH look like this:
http://robslink.com/SAS/democd44/ex_11.htm

I want to know if it is possible to add Canada and Mexico into the map like this:
http://www.mapsofnewmexico.com/AccordianTabs/USAMapsandGuides/USApop.php
SAS Employee
Posts: 967

Re: US Map

New Contributor
Posts: 3

Re: US Map

Any thoughts on keeping the north america map, but removing the province territories in MX and CA. Want to keep US states. Tried combining map code but can't figure it out. Thanks!

SAS Employee
Posts: 967

Re: US Map

Hmm ... I'm not sure exactly what you're asking.

If you want to use the north america map, without Mexico & Canada, you could just plot the areas where the 'id' (country id number) = 926 (that's the US).   Here's a very small/simplified example:

proc gmap data=maps.namerica map=maps.namerica (where=(id=926));

id id;

choro id / levels=1;

run;

If you want jus the US, and you want the state borders to show up, you could use maps.us or maps.states.

New Contributor
Posts: 3

Re: US Map

My apologies. Poorly worded.

 

I have shipment data I would like to plot in North America. I can do this
for US only already, but my company treats Canada and Mexico as basically the
51st and 52nd states so they want to include those as
well. I know how to get the NA map, but I can’t quite figure out how to remove
the territory lines so that MX and CA are treated as one area when I create a
prism map.

    

Hopefully that makes better sense. Thanks!

SAS Employee
Posts: 967

Re: US Map

Ahh! - Makes more sense now!

Since you don't want the internal boundaries within Canada & Mexico, you could either 'Proc Gremove' them, or you could use the country borders from maps.world.  Here's an example showing one way to do the latter:

%let name=namerica;
filename odsout '.';

data canada_and_mexico; set maps.world (where=(id in (595 260)));
/* Make their 'state' fips code be their country id# */
state=id;
length country $20;
if id=595 then country='Mexico';
if id=260 then country='Canada';
x=long;
y=lat;
run;

data us; set maps.states;
length country $20;
country='US';
run;

data custom_map; set canada_and_mexico us;
run;

proc gproject data=custom_map out=custom_map nodateline project=hammer;
id id;
run;

goptions device=png;

ODS LISTING CLOSE;
ODS HTML path=odsout body="&name..htm" style=sasweb;

goptions border cback=white;

proc gmap data=custom_map map=custom_map;
id state;
choro country / des='' name="&name";
run;

quit;
ODS HTML CLOSE;
ODS LISTING;

namerica.png

New Contributor
Posts: 3

Re: US Map

I had been attempting the first. I was using the gremove for CA and MX then combining states with the new CA and MX. Kept running into errors with my syntax though.

Your example is perfect. I can tweak a little to get exactly what I need.

Thank you very very much!

Ask a Question
Discussion stats
  • 6 replies
  • 377 views
  • 0 likes
  • 3 in conversation