BookmarkSubscribeRSS Feed
PhilMason
Obsidian | Level 7
I have imported mapping data for the UK from ESRI shape files using Proc MapImport, which worked very well. I then ran the mapping data through Proc Greduce to get a density variable for quicker mapping - which also worked well. I then use Proc Gmap with the choro statement to produce my map along with tooltips hovering over areas and the ability to click and drill down for lower level maps. This all mostly works, but my problem is that some of the areas in my map seem to be undefined or have errors. I can hover over most areas and get a tooltip, and the pointer turns to a finger indicating I can drill down. However when I hover over just a few areas on the map the pointer does not change, I get no tooltip and cant click to drill down. I am using IE6, although I did just try this in Chrome and the problem is still there.
Has anyone seen this behavior before and does anyone have any idea how to fix or get a workaround?

This is done on AIX, SAS 9.1.3.

thanks
Phil Mason
9 REPLIES 9
GraphGuy
Meteorite | Level 14
Sounds like you're on the right track ... hopefully just a few steps away!

If you run your code on the original map (before greduce), do the charttips work any better?

Are you using dev=activex, dev=java, or dev=png (or gif)? I recommend trying it with dev=png (or gif) ... activex and java can have some special 'quirks' (or extra features) when it comes to custom charttips & drilldowns.

Are you 100% certain that your response data has good/valid values for all the map areas? None of the strings are getting truncated short (before the closing quote within the string)?

Also, in v9.3, "proc mapimport" doesn't allow you to specify an 'id' variable, therefore it has to 'guess/intuit' what the id variable (and segment variable) are in the map. In v9.2, mapimport was enhanced to let you specify exactly which variable is the unique id, and it also has some other improvements. If possible, try upgrading to v9.2 and try the import again (or maybe ask a friend who already has 9.2 to import the map for you, and then you can use that imported map in your v9.1.3 SAS session).
GraphGuy
Meteorite | Level 14
See page 20 of this doc, for official info about the 'proc mapimport' enhancement in v9.2 ...

http://support.sas.com/kb/31/addl/fusion_31477_1_enhancementsandnewfeaturesinsas92robertallison.pdf
Darrell_sas
SAS Employee
My guess, based on the symptoms, is that it is the MAPIMPORT ID issue.
It may be that the id you are chosing for GMAP is not really a unique ID for the polygons.

You can try to find if there is a better ID variable by MAPIMPORTing the data with no restrictions (take everything in the shapefile) and then open the data set and see if there are any other choices that might be unique.

It is also possible that there is no unique ID variable in the shapefile data or that the unique variable isn't useful or the one you want. This was a common problem with US Census ZCTA data. The ZCTA variable isn't unique. The ID statement added at 9.2 re-sorts the data so that that variable is unique.
PhilMason
Obsidian | Level 7
You're a genius Darrell! (You too Rob :>) I took my shape files along to SAS 9.2 and imported them whilst also specifying the id I wanted, then took the coordinates back to 9.1.3 and suddenly everything worked. This is great since I am doing this for the UK government's Census Management Information System that I am building. I'll tell the deputy directors that you helped. Thanks, Phil
PhilMason
Obsidian | Level 7
I used SAS 9.2 to import the shape files, as Darrell suggested, which worked for all of the higher levels of geography.
I then got a shape file for a lower level and went through the same process and now find that I have a crazy looking shape. Looking at the coordinates it is a bit like it draws lines up and down like a heart monitor and then finally connects the last dot to the first one. This produces a series of triangles since all the ups and downs are bisected by the line back to the first coordinate. Is this likely to be bad shape data? Or is there something else I should do as I use Proc Mapimport to sort this problem out?
GraphGuy
Meteorite | Level 14
Could be bad map data, or something that's not working well with proc mapimport.

But the 2 most common things I've seen that cause points in maps to be connected in the wrong order (producing 'triangles') is ...

#1 - Sorting the map data (or doing something to the data set that causes the x/y points to be re-ordered ... sometimes proc sort, sometimes an sql join, etc).

#2 - Using a single id variable with a map that needs a compount id variable, or using the wrong variable(s) as the id.
Darrell_sas
SAS Employee
I agree. I generally look for a one of the problems Robert described.
We can only guess without seeing your data. You should probably contact Tech Support so they can examine the data.
PhilMason
Obsidian | Level 7
Thanks guys - once again the first thing you suggest turns out to be the solution. I was doing a SQL join with some other data on the map dataset, so that I could use a where and cut down the map data being used. This SQL join changed the sequence and messed things up. I just created a variable called obs which I set to _n_ in a data step, so I could remember the sequence of points - then I put an order by obs on my SQL join and it all worked. Thanks!
GraphGuy
Meteorite | Level 14
I've written a little example that might demonstrate the problem you're having ...
In this case, I declare the length of the html= variable too short, and it truncates the string (for some of the longer values, such as 'North Carolina') and therefore the charttips/drilldowns for just those areas with long-ish text don't work.

Often times, if you don't specify a length, SAS will choose one for you, and then later you might try to stuff a longer value into it (and, of course, the length of the string can't dynamically increase, so it truncates it!)


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

proc sql;
create table foo as select unique state from maps.us;
quit; run;

data foo; set foo;
length myhtml $45;
myhtml='href="http:\\www.sas.com" title='||quote(trim(left(fipnamel(state))));
run;

GOPTIONS DEVICE=png;
ODS LISTING CLOSE;
ODS HTML path=odsout body="&name..htm";

title1 "Charttip for long names is truncated and doesn't work";
proc gmap map=maps.us data=foo;
id state;
choro state / levels=1 coutline=gray nolegend html=myhtml
des="" name="&name";
run;

proc print data=foo; run;

quit;
ODS HTML CLOSE;
ODS LISTING;

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