BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
t75wez1
Pyrite | Level 9

Hello all,

Hello SAS technical support,

 By using “Proc SGMAP”, I created an U.S. map by state with version of ODS html5 file so that I can drill-down to any self-defined geo-area within single state map(total 49) if left mouse-clicking on the area of that state.

 

I can navigate those maps for myself within SAS system without any issue.

 

However, since most of my stakeholders who need to visualize those maps don’t have SAS system installed on their PC, thus I copied all of maps into the designated internal shared drive/folder. But it doesn’t work well and experiences unbearable long-time delay to open the html file for any state that has its size is greater than 3MB. The larger the size of file, the longer time to delay.

 

Any ideas how I can open them quickly and what's the catch?

 

Below you can find my SAS code.

 

Thanks so much for any help in advance.

 

Ethan

 

**********************************SAS code for creating U.S. map by state *********************;

%let drive=c:\temp;

libname data "&drive";

filename odsout "&drive.";
%let nameus=USMAP;
%put &nameus.;


%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;

data plot_usdata;
set mapssas.uscenter;
if state ^in(2,15,72) and ocean^='Y';
long = -long;
statename = fipstate(state);
run;
data US_state;set data.US_state;
length mylink $100;
mylink= 'c:\temp\'||compress(STATECODE)||'map.html';
run;


ods _all_ close;

ods html5 path=odsout file="&nameus..html" options(bitmap_mode="inline") style=mystyle nogtitle;
ods graphics on / reset antialiasmax=2000 tipmax=2000 imagemap=on
width=900px height=700px noborder;

TITLE1 justify=c color=purple height=19pt font='arial/bo' "U.S. Map" height=19pt color=dodgerblue " " height=19pt color=purple " " height=19pt color=dodgerblue " for Index";
title2 h=1pt " " ;

footnote f="arial/bo" h=4.5pt " " ;

footnote3 f="arial/bo" h=1.8pct color=blue justify=left " " justify=R h=1.8pct c=gray55
"%left(%qsysfunc(time(),tod7.)) %left(%qsysfunc(today(),weekdatx30.)) ";

proc sgmap mapdata=mapsgfk.us maprespdata=US_state plotdata=plot_usdata;
choromap index /
id=statecode mapid=statecode lineattrs=(thickness=0.5 color=grayaa) transparency=.01
tip=(state tot_pop median_income index ) TIPLABEL=('State' 'Total Population' 'Median Household Income($)' 'Index' )
colormodel=(&colorlist.) name="&nameus." url=mylink;
gradlegend "&nameus." / title="Index" TITLEATTRS=(Color=darkblue Family=Arial Size=9.5
Style=normal Weight=Bold) ;
text x=x y=y text=statename /
textattrs=(size=5.5pt color=black);
run;

quit;
ods html5 close;
ods preferences;

 

 

 

**********************************SAS code for self-defined geo-area within single state map (e.g in NC)  *********************;

 

%let drive=c:\temp;

libname data "&drive";

filename odsout "&drive.";
%let namest=NCMAP;
%put &namest.;


%macro stateloop(state);

%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="&namest..html" options(bitmap_mode="inline") style=mystyle nogtitle;
ods graphics on / reset=all outputfmt=png imagemap tipmax=25000
width=900px height=700px noborder;

TITLE1 justify=c color=dodgerblue height=17pt font='arial/bo' "Map in" height=17pt color=dodgerblue " " height=17pt color=purple " &stname." height=17pt color=dodgerblue " for Index";
title2 h=14pt " " ;

footnote f="arial/bo" h=4.5pt " " ;
footnote3 justify=R h=1.8pct c=gray55
"%left(%qsysfunc(time(),tod7.)) %left(%qsysfunc(today(),weekdatx30.)) ";

proc sgmap mapdata=data.NC_state maprespdata=data.NC_reported_data plotdata=data.NC_overlay_text;

esrimap url="https://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer";
styleattrs datacolors=(&colorlist.);
choromap &EQ. / mapid=lta_id id=lta_id
lineattrs=(thickness=0.5 color=grayaa) transparency=.01
tip=(LTA_ID tot_pop LTA_income index rank) TIPLABEL=('ID' 'Total Population' 'Median Household Income($)' ' Index' 'Index Ranking') colormodel=(&colorlist.)
name="&namest.";
gradlegend "&namest." / 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;


title1 h=15pt "Ranked by Index in" "A0"x height=15pt color=purple "&stname." ;
title2 color=grey h=8pt "(in descending order)";
footnote;
options pagesize=1000 nobyline;


proc report data=data.NC_reported_data style(header)=[background=white foreground=gray33] split='*'
STYLE(REPORT)={background=white font_size=1.2 cellpadding=2.6pt cellspacing=0pt}
STYLE(HEADER)={foreground=purple background=lightblue font_weight=bold font_size=9.5pt}
STYLE(COLUMN)={background=beige foreground=black font_size=1.8};

column ((" -- Area --" LTA ) ("Demo" tot_pop tot_birth LTA_income) (" " index rank) );
define LTA / "ID#" STYLE(COLUMN)={background=beige} width=9;

define tot_pop / analysis sum "Total Population" STYLE(COLUMN)={background=aliceblue};

define LTA_income /analysis mean "Median Household Income" STYLE(COLUMN)={background=aliceblue};

define index/ analysis mean "Index" format=comma7.0 STYLE(COLUMN)={background=wheat} width=5;
define rank/ "Ranking" STYLE(COLUMN)={background=wheat font_size=1.0} ;

rbreak after / summarize style=[font_weight=bold];

compute after;

LTA= 'Summary';

endcomp;
run;
quit;
ods html5 close;
ods preferences;

%mend stateloop;
%stateloop(NC);

1 ACCEPTED SOLUTION

Accepted Solutions
GraphGuy
Meteorite | Level 14

Rather than ...

mylink= 'c:\temp\'||compress(STATECODE)||'map.html';

 

Use the following if the drilldowns are in the same folder as the main html page ...

mylink= compress(STATECODE)||'map.html';

 

View solution in original post

9 REPLIES 9
GraphGuy
Meteorite | Level 14

When you create the state maps for each individual state, with the self-defined geo-areas, I suspect that your geo-areas probably have a lot more detail (more points along their borders) than you really need. You could use Proc Greduce to add a 'density' variable to your dataset, and then subset the dataset to only use the border points 'where density<=3' (or possibly <=2 or <=1 ... you could try it various ways, and see what gets you a small enough filesize but still provides enough detail in the borders). This way, when the html is generated describing the areas with mouse-over or drill-down, the html doesn't have to describe so many points along the borders ... and then the html file is smaller.

 

t75wez1
Pyrite | Level 9

Many thanks Rob for your prompt response.

 

I fixed the issue by subscribing to your suggestion on only using the border points 'where density<=2.

 

May I ask another question:

The SGMAP CHOROMAP statement needs to include the URL= option that points to a variable that contains the link for each state. For example:

 

For my output saved in c:\temp and the NC value in the US_STATE response data set the variable would look like:

data US_state;set data.US_state;
length mylink $100;
mylink= 'c:\temp\'||compress(STATECODE)||'map.html';
run;


I wonder whether I can make the location of drive/folder to output those HTML files implicit?

If I remember correctly, you've done similar things somewhere in your "Proc gmap" example from Robert Allison's SAS Graphics Examples! (robslink.com).

 

In other words, how to make portable for those HTML files without specifying the location for the url link? Because I need to copy those files to final shared drive/folder after QA process on my local drive/folder "c:\temp".

 

I could be wrong, any thoughts?

 

Thanks again for your help.

Ethan

GraphGuy
Meteorite | Level 14

In my multi-file drilldown examples, I put the drilldowns in the current directory or a subfolder of the current directory, and then put the relative path in the url (rather than the full path).

 

t75wez1
Pyrite | Level 9

Could you show an example about it?

Thx.

 

GraphGuy
Meteorite | Level 14

Rather than ...

mylink= 'c:\temp\'||compress(STATECODE)||'map.html';

 

Use the following if the drilldowns are in the same folder as the main html page ...

mylink= compress(STATECODE)||'map.html';

 

t75wez1
Pyrite | Level 9

Rob,

My issue is resolved. 

I'm very appreciative of both of your suggestion here!

 

 

t75wez1
Pyrite | Level 9

I stored the array of maps on company’s shared drive to let other people to view them. It works perfectly with drill-down feather. I tried to replicate them on our SharePoint with our IT support. It only works for me, but others can open each map individually and drill-down feature doesn't work after granting access permission to them.

How to fix it?

Thanks,

GraphGuy
Meteorite | Level 14

I'm not a big fan of Sharepoint, and have never tried to disseminate SAS html drilldown graphs on Sharepoint.

(maybe somebody else has some tips/experience?)

 

t75wez1
Pyrite | Level 9

Maybe Chris Hemedinger can help address the issue.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 9 replies
  • 3088 views
  • 1 like
  • 2 in conversation