SAS ODS destination - Google maps

➤ DISCLOSURE!

In June 2018 Google introduced changes to the way it handles its Maps platform. They now require API key in order to embed a map, plus Google Maps "projects" must now be associated with a billing account. Unless these new Google rules are met, Google maps described in the blog post will display with "For development purposes only" watermark but still retain its functionality.

You are all familiar with the traditional SAS Output Delivery System (ODS) destinations such as LISTING, HTML, PDF, or POWERPOINT that use “destination” in a sense of type of the output file. However, in this blog post, I am going to use term “destination” in even more traditional sense – as the place to which someone is going or to which something is being delivered.

Handpicked Related Content: The power of SAS-generated InfoWindows in Google maps

Marrying ODS destination with Google map destination

To be precise, I am going to use term “destination” for information delivery to a specific location on Google map. We will produce SAS ODS output and deliver it to particular locations on a Google map.

Since Google maps exist in the web page environments that are essentially HTML, the best suited ODS destination for such a “marriage” will be ODS HTML.

With this technique, we are not limited by mere texts or images placed on Google maps. We can place on Google map output of any SAS procedure – tables and graphs.

Here is an interactive example of delivering ODS output to a Google map destination/location (the data itself is totally fictitious and serves the purpose of illustrating the technique only). Please take a minute to explore this Google map interaction before reading further.

How it is done

Click to view and download the full sample SAS code. In this code, I capitalized on my prior posts on Google map with SAS. In particular, I used the idea of creating mini-pages for each location described in Weather forecasting with SAS-generated Google maps.

The main difference here is that the HTML mini-pages (place1.html, place2.html, etc.) for each geographical location were created using SAS ODS HTML destination, which illustrated by the following SAS macro:

%macro create_sas_outputs;

%let dsid = %sysfunc(open(places));
%let num = %sysfunc(attrn(&dsid,nlobs));
%let rc = %sysfunc(close(&dsid));

filename odsout "&proj_path\infopages";

%do j=1 %to &num;

data _null_;
p = &j;
set places point=p;
call symput('placename',place);
stop;
run;

ods html path=odsout file="place&j..html" style=styles.seaside;

goptions reset=all device=actximg colors=() htext=9pt hsize=3in vsize=1.5in;

title1 bold h=10pt color=cx3872ac "SAS user levels in &placename";
axis1 label=none;
axis2 label=none value=none minor=none major=none;

proc gchart data=sasusers(where = (place eq "&placename"));
vbar saslevel /
sumvar = count
width = 10
outside = sum
raxis = axis2
maxis = axis1
cframe = white nozero discrete
;
format count comma15. saslevel levelf.;
run;
quit;

ods html close;

%end;

%mend create_sas_outputs;

In this macro, for simplicity of the code sample I used PROC GCHART, but it can be any SAS procedure (PROC REPORT, PROC TABULATE - you name it) or a combination of several SAS procedures.

The rest of the technique is based on creating Google map InfoWindows that reference these HTML mini-pages via tag as shown in this code snippet:

put 'var info' i '= '' '';' /

I hope this post will serve as yet another illustration of the power of SAS as a tool for information delivery where it’s needed and when it’s needed.

What are your thoughts on this?

SAS ODS destination - Google maps was published on SAS Users.