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

I apologize if this is the wrong board, but since I am using PROC GMAP, I posted here. I am using SAS 9.4 TS1M5. 

 

I am new to mapping and I am trying to map Puerto Rico using the mapsgfk.us_all dataset supplied with SAS. I need the map to be at the county (municipio) level. When I create the map using this dataset, it maps it at the county subdivision level. My data is still mapping correctly (filling up each sub division to fill the entire county), but considering my data is at the county level I would rather not give the impression my data is more granular. Does anyone know of a way to remove the subdivision lines and only show the major county lines? The odd thing is that it seems Puerto Rico has more granular information than the rest of the US in this file. When using the ID field in mapsgfk.us_all for the id statement in PROC GMAP, it maps all of the US correctly using a code such as 'US-15001' and the ID2 field is empty, but for Puerto Rico data, the ID field looks more granular such as 'PR-7200100401' and the ID2 field looks more like the other identifiers 'PR-72001'. When I try to use ID2 to map the data, it looks very distored. I included code below which maps Puerto Rico at the subdivision level and I included images of what the non-distorted map looks like (using ID) and what the distorted map looks like (using ID2 which seems to be at the county level). I have tried using PROC GREDUCE, but it seems like this is not solving the problem but I wonder if it is needed here. If anyone knows how to only map the county lines and not the subdivision lines, I would greatly appreciate it. Thank you!

proc gmap map=mapsgfk.us_all data=mapsgfk.us_all ;
   id id;
   choro state / nolegend ;
   where statecode="PR";
run;
	quit;

Non-distorted PR.pngdistorted PR.png

1 ACCEPTED SOLUTION

Accepted Solutions
mitchell_keener
Obsidian | Level 7

Well FWIW I believe I answered my own question. This requires PROC GREMOVE and not PROC GREDUCE. I will leave this up in case it happens to help someone down the road. 

 

Fairly simply done using this code. 

data PR;
	set mapsgfk.us_all;
	where statecode="PR";
	run;

proc gremove data=PR out=PR2;
	by id2;
	id id;
run;



proc gmap map=PR2 data=PR2 all ;
   id id2;
   choro state / nolegend ;
   where statecode="PR";
run;
	quit;

 

View solution in original post

3 REPLIES 3
mitchell_keener
Obsidian | Level 7

Well FWIW I believe I answered my own question. This requires PROC GREMOVE and not PROC GREDUCE. I will leave this up in case it happens to help someone down the road. 

 

Fairly simply done using this code. 

data PR;
	set mapsgfk.us_all;
	where statecode="PR";
	run;

proc gremove data=PR out=PR2;
	by id2;
	id id;
run;



proc gmap map=PR2 data=PR2 all ;
   id id2;
   choro state / nolegend ;
   where statecode="PR";
run;
	quit;

 

mkeintz
PROC Star

@mitchell_keener 

 

Glad you found the answer to your question.    Go ahead and mark your own answer as the solution.

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
GraphGuy
Meteorite | Level 14

Nice job of self-help, Mitchell!

 

Here are a couple of suggestions you might want to add...

 

When you subset your map to PR, I recommend dropping the resolution variable. The mapping procs (such as gmap) automatically apply reduce the number of points used in drawing the map, based on the size of the output ... but when you subset just a piece of a larger map, this throws off the calculations, and the results might or might not look good. If you delete the resolution variable, then the automated algorithms will not be applied.

 

After you get rid of the resolution variable and disable the automated system, then I recommend using the density values to just use the number/level of pixels detail as looks good to you. I tried several different settings, and I think density<=3 looks pretty good (not too sparse, and not too crowded borders).

 

And when I create a new map, I always like to use some test data with the map area names in it, and use that as mouse-over text (with gmap's html= option). You can see a sample mouse-over in the screen-capture below:

 

data PR; set mapsgfk.us_all
(where=(statecode="PR" and density<=3) drop=resolution);
run;

 

proc gremove data=PR out=PR2;
by id2;
id id;
run;

 

proc sql noprint;
create table pr2_data as
select unique id2, id2name, 'title='||quote(trim(left(id2name))) as my_html
from mapsgfk.us_all_attr;
quit; run;

 

title1 ls=1.5 "Puerto Rico Municipios";


goptions xpixels=800 ypixels=350;


proc gmap map=PR2 data=pr2_data all ;
id id2;
choro id2name / nolegend html=my_html;
run;

 

pr.png

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 839 views
  • 3 likes
  • 3 in conversation