Running SAS PROCs on your Facebook Friends


Question: What do you get when you cross your Facebook friends with SAS analytics?

Answer: Insight, probably more about yourself than anything else. You can tell a lot about yourself by looking at your friends. And I'll bet that so can Facebook and those who advertise on it.

Note how most of my friends are MUCH older than me

Data from social media sites is ripe for analysis, and Facebook data is more structured than most. I've developed an application that turns your Facebook friends data into a SAS program so that you can run reports and analytics on them. Some reports are easy to understand, such as the above chart that buckets my friends into "life stages" based on graduation years. Or you can leverage the heavy duty analytics, such as this correspondence analysis from PROC CORRESP (hover your mouse over the image for a more technical explanation).

Um, sorry...I do not really know what this means

I developed the application as an example task for SAS Enterprise Guide 4.2 for a book that I'm working on. I'm a ways away from being done with the book, but we are so keen on Twitter, Facebook, and social media in general right now that I decided to share it early.

If you aren't using SAS Enterprise Guide 4.2, you're not completely out of luck. You can also run the application on its own to create the program, and then run the program in SAS 9.2 however you want. The program produces:

  • A SAS data set with your Facebook friends data, one record for each friend
  • PROC REPORT output with the current status information from your friends
  • The plots shown above, for years since graduation and correspondence analysis
  • More data sets containing your friends favorite books and movies, produced with brute force DATA step scraping.

You can download the task/program from here. Instructions for deployment and use are in the README.txt file in the ZIP archive. Note: you'll need Microsoft .NET 3.5, a Facebook account (of course), and you'll need to allow my registered application ("ImportToSAS") to access your account information. Don't worry; none of your Facebook information is gathered/stored anywhere except for in the resulting program file.

Manifest of technologies includes: Facebook Toolkit for .NET (to connect to Facebook and gather data), XML Libname engine along with XML Mapper (to get the "friends" data into data sets), the SGPLOT procedure (to produce bar charts), ODS tagsets.htmlpanel (to control report layout for side-by-side charts), ODS Graphics in SAS/STAT (for correspondence plot), and custom task APIs for running within SAS Enterprise Guide.


About Author

Chris Hemedinger

Director, SAS User Engagement

+Chris Hemedinger is the Director of SAS User Engagement, which includes our SAS Communities and SAS User Groups. Since 1993, Chris has worked for SAS as an author, a software developer, an R&D manager and a consultant. Inexplicably, Chris is still coasting on the limited fame he earned as an author of SAS For Dummies


  1. Richard Thomas on

    Hello Chris,

    Nice! Any chance of getting source code for this?


  2. Richard,

    Yes, I'll work on a version of the source code that I can share out. I developed this as an example, so the source code will come in handy to show what you can do with custom tasks in EG.


  3. Ralph Winters on

    Nice example of how to use SAS to perform basic social networking analytics.

    Ralph Winters

  4. Hi Chris,
    I really like this application. Is it possible to adapt the code to extract information from a fan page?


  5. Very interesting tools to enlarge sas capabilities on the web . I'd tried it . Nice...

  6. Catalin Manoliu on

    Hi Chris,

    Very cool sample.

    I am looking for some documentation on developing custom task add-ins for the new 4.2 version of Enterprise Guide.

    I've already built custom task add-ins for the 4.1 version and a small .Net library which provides an abstraction layer (a facade) when consuming SAS "services" from .Net code and now I'm considering migrating those for the 4.2.

    Still now I only found 2 samples on the web (SAS.Tasks.Examples.GKPI.dll and yours) and I see that all are requiring the "SAS.Tasks.Toolkit.dll" assembly.

    Can you please provide a link to some place where I cand download the required tools (SAS Task Toolkit, for ex) and other samples for creating EG 4.2 add-ins ?


    Catalin Manoliu

  7. Pingback: Your million and one uses of SAS - The SAS Training Post

  8. Pingback: Yeah, I’ve got that problem too. - The SAS Dummy

  9. Pingback: Hooo-ray for Hollywood - The SAS Dummy

  10. Pingback: SAS Professionals know how to party - The SAS Dummy

  11. Hi Chris - I know this is an older post, but I'm wondering if this has been updated as I can't get this version to run (invalid paramater). And do you have the source code so I can debug myself? Great app. just want to explore a bit more - Thanks,

Back to Top