Tuesday, April 3, 2012

Leveraging JQuery Widgets - An Events Calendar

This example is a bit of a teaser as I am going to illustrate a capability that I think is very cool - it illustrates the integration of a resource found on Web - but I am not going to include or discuss the code (which is actually a SAS Server Page). At least, not yet.

All of us programmers know about copying and modifying something that already exists instead of building something from scratch. And the Web, with the help of a Google search, provides a rich source of samples and starting points for readers to create their own SAS Server Pages.

So the idea for this example was born when a fellow consultant asked me (and a few others) a while back about whether I knew of a way to publish an events calendar on the SAS Portal. And before I had a chance to even think about it, Vince DelGobbo of SAS R&D suggested that maybe this could be done using SAS Server Pages (and PROC STREAM). So after a simple Google search, I found the FullCalendar plugin for JQuery.

And everyone reading this can probably guess that it was not too hard to create a calendar from data in a SAS Data Set. In fact, the hardest part was figuring out a set of events data I could use. Then it struck me - a calendar of blog postings about PROC STREAM which you can see here:
These both use the sasServerPage macro and the same source program (which can be run as both a Stored Process and a SAS/IntrNet Application Dispatcher program) as discussed in my last blog posting. The events data are my blog postings about PROC STREAM and SAS Server Pages. For blog postings I've already published, the events are hyperlinked; for future postings, the events are my best guess (at the time this blog was published) of what I plan to blog about between now and SAS Global Forum 2012.

The details of how I did this with PROC STREAM will be discussed in a future blog (sometime after SAS Global Forum 2012). But for now let me say that at the 10,000 foot level, it was pretty simple:
  1. Downloaded the code from the FullCalendar site (note that it can be used without restricion under the MIT License).
  2. Modified one of the demo programs replacing the hardcoded event data with a SAS macro that reads the data set of event data and generates JSON (JavaScript Object Notation).
  3. And thanks to the %let technique to handle HTML entities (© in this case) discussed in my last blog posting I did not have to worry about SAS attempting to resolve Named HTML Entities as macro variable references.
That's all there was to it. I promise!

No comments:

Post a Comment