BookmarkSubscribeRSS Feed
t75wez1
Pyrite | Level 9

Hi All,

I created the map with the numbers of self-defined areas with tooltip showing certain statistics using “Proc SGMAP”.

But somehow the tooltip disappeared for some of areas.

 

Below is the map with labels indicated NW or W if the tooltip disappeared or not.   

NW=doesn’t work

W=work

Any ideas on how to fix my code below?

 

Thanks so much for your helps.

Ethan

 

********************************************************SAS code**********************************************************************************

 

 %let name=MAPstate;

%let colorlist=cx4dac26 cxb8e186 cyan  cxf1b6da cxd01c8b;

ods path(prepend) work.templat(update);

proc template;

  define style mystyle;

    parent=styles.htmlblue;

    class GraphValueText /                                                 

    font = (Arial,7.5pt,Bold)                                 

     color = black;

  end;

run;

ods _all_ close;

ods html5 path=odsout file="&name..html" options(bitmap_mode="inline") style=mystyle nogtitle;  

      ods graphics on / reset=all outputfmt=png imagemap tipmax=25000  

 width=900px height=700px noborder;

 

proc sgmap mapdata=remstate maprespdata=latest_reported_data1  plotdata=overlay_text1;

esrimap url=https://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer;

styleattrs datacolors=(&colorlist.);

choromap &EQ. /   mapid=id id=id 

 lineattrs=(thickness=0.2 color=grayaa) transparency=.01

tip=(ID NAME pop pop_perc income index rank) TIPLABEL=('ID' 'Name'  'Pop' '% of POP' 'Income($)' 'Index' 'Index Ranking')  colormodel=(&colorlist.)

name="&name.";

gradlegend "&name." / title="Index" TITLEATTRS=(Color=darkblue Family=Arial Size=9.5

        Style=normal Weight=Bold) ;

 

series x=outlinex y=outliney / group=grp lineattrs=(color=black thickness=0.03px);

run;

quit;

ods html5 close;

ods preferences;

 

t75wez1_0-1681240330249.png

 

6 REPLIES 6
ballardw
Super User

Doesn't work is awful vague.

Are there errors in the log?: Post the code and log in a code box opened with the "</>" to maintain formatting of error messages.

No output? Post any log in a code box.

Unexpected output? Provide input data in the form of data step code pasted into a code box, the actual results and the expected results. Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the "</>" icon or attached as text to show exactly what you have and that we can test code against.

 

Which data set holds the tip values?

Have you double checked that the tip data has the same values as the map data for the areas? A minor thing like one value being "AB" in one location and "Ab" in the other can mean the linkage doesn't complete as AB is not equal to Ab.

 

Have you opened that HTML5 in a text editor to see if there are links that point to odd locations in case the tips were just written in an an expected location?

 

It might help to provide data sets and the definition of the macro variable &EQ.

t75wez1
Pyrite | Level 9

Thanks @ballardw.

 

Below is my simple version SAS code & log as well as the attached input data sets. One of input file is saved as CSV other than SAS due to the size of file exceeding the limit to attach.

 

The running time for Proc SGmap alone is nearly 20 second without any errors.

 

Could you enlighten me on why the tooltips disappear for some of IDs on the map.

 

Thanks so much for your help.

 

 

%let drive=c:\temp;

libname temp  "&drive.";

data text1;set temp.text1;

run;

 

data reported_data1;set temp.reported_data1;

 

run;

 

proc import out=MTstate

 

datafile="&drive.\MTstate.csv"

 

dbms= dlm replace;

 

delimiter = ',';

run;

 

data MTstate(rename=(IDNew=ID));set MTstate;

length IDNew $4;

IDNew=put(ID,z4.);

drop ID;

run;

 

%let EQ=index;

%let colorlist=cx4dac26 cxb8e186 cyan  cxf1b6da cxd01c8b;

%let name=MTMAP;

filename odsout "&drive.";

 

ods path(prepend) work.templat(update);

proc template;

  define style mystyle;

    parent=styles.htmlblue;

    class GraphValueText /                                                 

    font = (Arial,7.5pt,Bold)                                 

     color = black;

  end;

run;

 

ods _all_ close;

ods html5 path=odsout file="&name..html" options(bitmap_mode="inline") style=mystyle nogtitle;  

      ods graphics on / reset=all outputfmt=PNG imagemap tipmax=35000   ANTIALIAS=on ANTIALIASMAX=10000 SUBPIXEL=on

width=900px height=700px noborder;

 

proc sgmap mapdata=MTstate maprespdata=reported_data1  plotdata=text1;

openstreetmap;

styleattrs datacolors=(&colorlist.);

choromap &EQ. /   mapid=id id=id 

 lineattrs=(thickness=0.2 color=grayaa) transparency=.01

tip=(ID  pop pop_perc  index rank) TIPLABEL=('ID'   'Population' '% of Population'  'Index' 'Index Ranking')  colormodel=(&colorlist.)

name="&name.";

gradlegend "&name." / title="Index" TITLEATTRS=(Color=darkblue Family=Arial Size=9.5

        Style=normal Weight=Bold) ;

 series x=outlinex y=outliney / group=grp lineattrs=(color=black thickness=0.03px);

run;

quit;

ods html5 close;

ods preferences;

 

 

GraphGuy
Meteorite | Level 14

I downloaded your data in the zip file, and experimented with it a bit in the "SAS OnDemand for Academics" (which might not be the same version of SAS you have, so your results may vary)...

 

I noticed that the default tips for the black outline drawn by the 'series' statement interfered with some of the 'choromap' area tips. I doubt you really want the tips along the black line(?), therefore I suggest using tips=none for the series statement.

 

Also, the csv that has the points along the border of the choromap areas is a bit big/detailed, with almost 500,000 points. If you have SAS/Graph, you can use Proc Greduce, and then only take the points with lower density (for example, density<=1 yields map dataset with about 14,000 (instead of 500,000) - to the naked eye, and the limited screen pixel resolution, the 14k points look about the same as the 500k points. This will make it easier for the browser to handle the tip areas.

 

Here's the modified code I used, and I saw tips on all the colored map areas:

 


libname temp "/home/u59782200/";
data text1;set temp.text1;
run;
data reported_data1;set temp.reported_data1;
run;
proc import out=MTstate
datafile="/home/u59782200/MTstate.CSV"
dbms= dlm replace;
delimiter = ',';
run;
data MTstate(rename=(IDNew=ID));set MTstate;
length IDNew $4;
IDNew=put(ID,z4.);
drop ID;
run;
proc greduce data=mtstate out=mtstate;
id id;
run;
data mtstate_reduced; set mtstate (where=(density<=1));
run;

ods graphics / imagemap tipmax=35000;

proc sgmap mapdata=MTstate_reduced maprespdata=reported_data1  plotdata=text1;
openstreetmap;
styleattrs datacolors=(cx4dac26 cxb8e186 cyan  cxf1b6da cxd01c8b);
choromap index / mapid=id id=id 
 lineattrs=(thickness=0.2 color=grayaa) transparency=.01
 tip=(ID  pop pop_perc  index rank) 
 TIPLABEL=('ID'   'Population' '% of Population'  'Index' 'Index Ranking')  
 colormodel=(cx4dac26 cxb8e186 cyan  cxf1b6da cxd01c8b)
 name="foo";
gradlegend "foo" / title="Index";
series x=outlinex y=outliney / group=grp lineattrs=(color=black 
   thickness=0.03px) tip=none;

 
t75wez1
Pyrite | Level 9

@GraphGuy Thanks very much for your helps again!

But in this case running "proc greduce" takes about 4 minutes to finish it.

Other than that I'm gleeful for the results based on your suggestions.

My SAS version is Base 9.4 (TS1M7), I need to replicate the process to create map for over 40 times.  is there any catch to reduce the running time for "proc greduce"?

 

 

GraphGuy
Meteorite | Level 14

After you run proc greduce on a map once, and eliminate the high-density points, you can save & re-use the map dataset rather than running proc greduce again (unless each map is unique/different?)

t75wez1
Pyrite | Level 9

Thanks very much for your guidance and suggestions once again.

 

This has allowed me to experience the power of Proc SGMAP, particularly go through the hump to deal with the large size of geo-data.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 1336 views
  • 1 like
  • 3 in conversation