BookmarkSubscribeRSS Feed
MarcTC
Obsidian | Level 7
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
6 REPLIES 6
GraphGuy
Meteorite | Level 14
stemajordavis
Calcite | Level 5

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!

GraphGuy
Meteorite | Level 14

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.

stemajordavis
Calcite | Level 5

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!

GraphGuy
Meteorite | Level 14

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

stemajordavis
Calcite | Level 5

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!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 6 replies
  • 982 views
  • 0 likes
  • 3 in conversation