The power of SAS-generated InfoWindows in Google maps

In my prior posts on displaying Google maps in SAS, I used Google map InfoWindows to display text information when user clicks on a marker or area of the map.  Thanks to reader Tom Bellmer’s questions, today I am going to explore some additional possibilities that the Google map InfoWindow can provide.

According to the Google Maps documentation, the content of the Info Window may contain a string of text, a snippet of HTML, or a DOM element. Let’s use that “snippet of HTML” creatively.

I am going to expand the earlier example, Live Google maps in SAS -- multiple markers by enhancing the InfoWindow so that, in addition to text, it includes hyperlinks, images and even embedded YouTube video. There are just two differences of this code from the prior implementations of the Google map with markers and info windows. These differences are: 1) the data preparation step shown below and 2) the line of the code that defines the contents of the InfoWindow. This example also uses a simpler method for handling quotes.

Adding new variables to the source data

To make our example data-driven, we add the following data columns to the source data: manager name, e-mail, website url, manager picture, youtube id. To make our SAS code self-contained, we will create our source data within the code itself:

/* data preparation */
data organizations;
  length
    oname $15
    addr1 $20
    addr2 $20
    phone $15
    lat 8
    lng 8
    pname $15
    email $12
    web $10
    pic $10
    utub $13
    ;
  input
    oname $ 1-14 addr1 $ 16-35 addr2 $ 37-55 phone $ 57-70 lat 72-80 lng 82-91
    pname $ 93-107 email $ 109-120 web $ 122-128 pic $ 130-137 utub $ 139-149;
  datalines;
SAS Institute  111 Rockville Pike   Rockville, MD 20850 (301) ###-5555 39.086137 -77.149283 Robert Anderson ra@org_A.com sas.com img1.jpg ksp8CzIgb-E
Organization B 14200 Shady Grove Rd Rockville, MD 20850 (301) ###-3333 39.092048 -77.207544 Kerri Evers     ke@org_B.com sas.com img2.jpg tv9oaq1b4zI
Organization C 14501 Avery Rd       Rockville, MD 20853 (301) ###-8888 39.093247 -77.122915 Medea Colchis   ps@org_C.com sas.com img3.jpg K5qTKCzI2Ek
;
run;

Note: while geographical locations in this example are real (they have to be real in order to show up on a Google map), some names as well as the contact information are fictitious. The YouTube videos from SAS are real!

Download the full sample SAS code here.

Defining the contents of the InfoWindow

In the prior implementation, the line of the code starting with 'var info' that defines the contents of the InfoWindow was quite simple:

'var info' i "= '" '<div style="' 'width:150px;"><b>' oname "</b><br>" addr1 "<br>" addr2 "<br>Phone: " phone "</div>" "';" /

For today’s purposes, this line naturally becomes somewhat more intense. In this code snippet, there are HTML tags with inline styles defining the layout and appearance of information in the InfoWindow and variable values that are fed from the source SAS data set. For the YouTube video, I use <iframe> tag, which allows embedding any external web contents.

'var info' i '=''<div style="width:470px;height:300px;"><div style="float:left;margin-top:5px;margin-right:5px;"><b>'
    oname '</b><br>' addr1 '<br>' addr2 '<br> Phone: ' phone '<br><a href="http://www.' web +(-1) '" target="_blank">Website</a><br>Manager: '
    pname '<br><img src="images/' pic +(-1) '" style="margin:3px;"><br><a href="mailto:' email +(-1) '">E-mail</a></div>'
    '<div style="float:right;margin-top:40px"><iframe width="295" height="227" src="//www.youtube.com/embed/'
    utub +(-1) '" frameborder="0" allowfullscreen></iframe> </div> </div>'';' /

Simpler method for handling quotes

Please note, that in the prior code I used both, single and double quotes to secure proper quotation. However, in the new code, I relied on a simpler approach - dual single quotes when the first single quote serves as a masking or escape character for the second single quote.

In other words, within a SAS character expression, dual single quotation mark resolves to a single quotation mark being a part of the character value and not a closing quotation mark. The same is true for dual double quotation marks (see Using Quotation Marks with Character Constants in the documentation.)

Although in many cases this might be superfluous, I use the +(-1) pointer control expression to secure clean (without an extra space) double quotation mark closure. This technique becomes essential when you construct Javascript variable property references using dot notation.

Implementation

In this code, the assumption was made that if the location of the output HTML file is the c:\\ folder (as shown in the code), then the images are stored in c:\\images folder. For the Youtube videos to be functional within the InfoWindows, the output HTML files have to be viewed on the web server, not on your local computer.

Running the above code sample produces the gmapoutput_iw.html file, which, when opened in a web browser, produces a Google map containing markers as shown in the image below.

In this example, not only is this Google map interactive (you can move it around, zoom in, zoom out, change view between Street View, Satellite View and Terrain View), you can also click on markers to display detail information about that location in a popped information window. The content of InfoWindows itself is interactive too.  You can click on a hyperlink to go to a website, or click on an e-mail link to send an e-mail, or watch a YouTube video and interact with it (view and listen, pause, play, adjust volume, fast forward and backward.)

Click on the Google maps image to see an interactive version.  Alternatively, you can click here for an interactive version of the map.

Screenshot of a SAS-generated interactive Google map with image, hyperlinks and Youtube video displayed in Info Window

Enhanced InfoWindows can be used not just in conjunction with Google map markers, they can also be used in a similar manner with Google map overlays shown in my prior post Drawing overlays on SAS-generated Google maps.

I hope this post gives you more “food for thought” on possible Google map visualizations in your SAS applications. Please, continue sending your feedback, ideas and questions by commenting on this post.

Post a Comment

Transitioning to 64-bit SAS on Windows

The major benefit of 64-bit applications is that they no longer have the memory limitation imposed by their 32-bit predecessors. This is why many SAS customers are making the transition from 32-bit SAS to 64-bit SAS. The move to 64-bit SAS can be daunting at first sight. There are many questions which quickly come to mind:

  • What are the benefits of 64-bit?
  • Will my existing 32-bit data work with 64-bit SAS?
  • What problems might I encounter?

Here are some resources which might answer your questions and ease your transition:

Making the decision: benefits of 64-bit

About the data

Microsoft Office Data (PC Files Server for SAS 9.3 and SAS 9.4)

Potential problems

Post a Comment

Drawing overlays on SAS-generated Google maps

In this post, I am going to expand on my prior posts, Spice up SAS output with live Google maps and Live Google maps in SAS -- multiple markers to explore some new functionality.

Using similar techniques, I'll demonstrate how to draw a closed geometric shape, in particular, a polygon, on a Google map. Well, let’s make it more than one polygons – two for simplicity. Overlaying polygons on a Google map is a great visualization for geographical and administrative regions, such as countries, states, counties, school districts, areas of services, etc. Besides, practically any shape can be approximated by a polygon with a large enough number of vertices. Here's an example what we are going to get: Read More »

Post a Comment

SAS Global Forum 2015—the place to learn more about analytics

Ever wondered where to find analytics experts to get your countless questions answered or where to find qualified talent to grow your industry? The simple answer to these questions is just one event – SAS Global Forum 2015 in Dallas, TX April 26-29.

Every year, the SAS Global Users Group plans and sponsors SAS Global Forum where SAS’s cutting edge technology gets showcased along with dozens of workshops, presentations, demos and networking opportunities. This is also the place you can learn how industry giants are using hot technologies such as visual analytics, Hadoop, in-memory computing and more.

Now, supersized datasets with billions of rows are the norm rather than the exception. Equally important, the variety of data being analyzed – from numeric to text to audio to video – has grown tremendously. Where can you see cool applications using such diverse data for making better decisions? From beginner to expert, from academic to commercial – SAS Global Forum 2015 has something to offer every skill level and application. Read More »

Post a Comment

SAS Visual Analytics 6.4: Importing a Twitter Stream

Great news.  If you’ve been struggling to import a Twitter stream as a data source, SAS Visual Analytics 6.4 has greatly simplified that task as part of this release’s expanded data import functionality. The first time you import tweets, you are directed to the Twitter website to log on to your account and authorize SAS Visual Analytics. After the initial logon, SAS Visual Analytics uses authorization tokens for accessing Twitter instead of requiring you to log on each time.

 The product documentation provides high level instructions for how to import tweets from Twitter, but I found that additional detail makes the process much simpler to follow.  In this post, I’ll walk you through the process from beginning to end, with screenshots and helpful hints along the way. Read More »

Post a Comment

8 most attended SAS administrator papers in 2014

In a comment on last week’s blog asking SAS administrators: please submit your paper idea for SAS Global Forum 2015, Andrew Howell of ANJ Solutions asked if I had any statistics on which were the most popular SAS administrator papers for last year’s conference. He suggested the following nominations although he was “only able to attend about half of these presentations—there was just so much to see!” 

I don’t have any readily available statistics on downloads for these papers, and, like Andrew, I wasn’t able to attend all of the excellent SAS Administrators sessions at SAS Global Forum 2014. But based on my own observations and feedback from others who were able to attend, here’s my very subjective ranking of Andrew’s list!

  1. Effective Usage of SAS Enterprise Guide in a SAS 9.4 Grid Manager Environment, Edoardo Riva, SAS
  2. SAS Grid – What They Didn’t Tell You, Manuel Nitschinger, sIT Solutions and Phillip Manschek, SAS
  3. Best Practices for Implementing High Availability for SAS 9.4, Cheryl Doninger, Zhiyong Li and Brian Wolfe, SAS
  4. SAS Installations: So You Want To Install SAS?, Rafi Sheikh, Analytics International
  5. Top 10 Resources Every SAS Administrator Should Know About, Margaret Crevar and Tony Brown, SAS
  6. SAS Grid Manager I/O: Optimizing SAS Application Data Availability for the Grid, Gregg Rohaly and Harry Seifert, IBM
  7. Test for Success: Automated Testing of SAS Metadata Security Implementations, Paul Homes, Metacoda
  8. Integrating Your Corporate Scheduler with Platform Suite for SAS® or SAS® Grid Manager, Paul Northrop, SAS Australia

Last year’s conference was a great opportunity for “seeing SAS Administrators in their natural habitat”.  Many of these sessions were standing room only.  Please submit your paper idea and let’s plan for another great year for administrators!

Post a Comment

Macro quoting made easy

Are there times when you need to pass special characters to a macro variable but cannot find the right technique to accomplish the task?  In this article I’ll discuss the different macro quoting functions and give a simple technique to help you determine which macro quoting function to use.

Why do we need macro quoting?  The SAS macro language is a character-based language. With macro, you can specify special characters as text.  Some of these special characters (for example, a semicolon or percent sign) are part of the SAS language instruction set, so we need a way for the macro processor to interpret a particular special character when it’s being used as text in the macro language.  Macro quoting functions tell the macro processor to treat these special characters as text rather than as part of the macro language.  Without macro quoting functions, you would have no way to mask the real meaning of these special characters or mnemonics.

This post will list some all-purpose functions, tell how to determine when to use each type, and show you how to unmask, or unquote special characters. Read More »

Post a Comment

SAS administrators: please submit your paper idea for SAS Global Forum 2015

The SAS Global Forum 2015 Call for Papers opened the end of last month!  I cannot believe it is time to start getting ready for the conference that will be in Dallas, TX on April 26-29, 2015.

As part of the group from SAS who goes to the conference each year to help the attendees with their administration questions, I would like to issue a personal invitation to all the readers of this blog to submit an abstract on SAS administration tips that have made your role as the SAS Administrator at your site easier, or things that you wish you had known before you took over the role of SAS Administrator.  These tips can be from setting up your hardware infrastructure to deploying your SAS applications to supporting your SAS users. Read More »

Post a Comment

MWSUG 2014 – guided learning, a cruise and more

MWSUG 2014 logo showing Chicago skyline and 25th anniversary bannerThis fall, you’ll be swept off your feet in the Windy City: The 2014 Midwest SAS User’s Group (MWSUG) takes place in Chicago from October 5-7. With 135 presentations in 11 different sections, you’ll have the chance to expand your SAS know-how and network with fellow SAS professionals. Read More »

Post a Comment

SAS administrators--what's on your bookshelf?

I spend a lot of time on support.sas.com looking for resources to share.  The SAS Programmer’s Bookshelf is a handy reference that’s been around for a while, so I asked “Why not a SAS Administrator’s Bookshelf?”

What would you include?

It’s complicated, of course, because the SAS administrator’s role covers a myriad of tasks. Throw into that mix, the fact that many individual software products have their own administration requirements, and you have quite a long list.

About a year ago, I published a post on SAS administrator connections and resources, and all this research made me realize it might be time to update that post with a few new items (noted with *). Read More »

Post a Comment