Friday, October 3. 2008Mining the VP debate results according to Twitter -- with SASTrackbacks
Trackback specific URI for this entry
No Trackbacks
Comments
Display comments as
(Linear | Threaded)
Now that's really cool! Glad to hear you are connecting SAS technology with the latest in both technology and political trends. Keep up the great work!
James I think you need to replace the last line from run; to quit; else sgplot keeps running. I tested it on 92p.
Paul, good catch. I neglected to mention that I was using SAS Enterprise Guide to develop/run this program, and it adds the QUIT; for you. I've updated the source in the example.
Chris The atom feed is so simple that you don't even need xml mapper. Combined with the sophisticated search parameters on twitter.com, it can be as simple as below:
/ get upto 100 "tweets" posted on oct. 3, 2008, with the hash tag vpwinner and either "biden" or "palin" in its title / %let home = http://search.twitter.com/; %let search = search.atom?q=+%23vpwinner; %let date = +since:2008-10-03+until:2008-10-03; %let ors = %nrstr(&)ors=biden+palin; %let lang = %nrstr(&)lang=en; %let rpp = %nrstr(&)rpp=100; filename page url "&home&search&date&ors&lang&rpp"; data winners; infile page lrecl=32767; input; prxTitle = '//i'; prxBiden = '/#vpwinner[\s\-\:]+biden/i'; prxPalin = '/#vpwinner[\s\-\:]+palin/i'; if prxmatch(prxTitle, infile) then do; if prxmatch(prxBiden, infile) then winner="Biden"; else if prxmatch(prxPalin, infile) then winner="Palin"; output; end; run; filename page clear; proc freq data=winners; tables winner; run; / on lst The FREQ Procedure Cumulative Cumulative winner Frequency Percent Frequency Percent ----------------------------------------------------------- Biden 31 75.61 31 75.61 Palin 10 24.39 41 100.00 Frequency Missing = 27 / Chang,
Thanks for the comments and the simplified SAS program! The advantage of the XML Mapper approach is that you then have all of the tweets in a SAS data set, ready for other analysis if you want. Chris |
ABOUT CHRIS Chris Hemedinger is a senior software manager in SAS R&D. He's part of the team that builds SAS Enterprise Guide and SAS Add-In for Microsoft Office. He's also co-author of the popular SAS for Dummies book and moderator of the SAS Enterprise Guide discussion forum.
QuicksearchOther SAS BlogsBI and Chicken Pot PieConversations and Connections Data Flux Community of Experts Closing the Intelligence Gap In Other Words In the Final Analysis JMP Blog Key Happenings at support.sas.com The New Lending System The Text Frontier SAS Global Forum Blog sascom Voices Blog A Shot in the Arm All SAS Blogs Recent postsCustom tasks that do the job
31Jan2010 Who's who in your SAS metadata environment 27Jan2010 Numero Uno 21Jan2010 Predictive analytics vs. forecasting: what's the difference? 15Jan2010 Fun and fashion at SAS Global Forum 2010 08Jan2010 Why I review SAS Press books 08Jan2010 "You have Jail" 04Jan2010 SAS Enterprise Guide for Programmers: The Movie 21Dec2009 Greatest hits from 2009 16Dec2009 SAS Talks: You listening? 10Dec2009 BOOKS & VIDEOSSAS for Dummies -- If you want to learn to be productive using the latest SAS tools and technologies in your daily work, but don't necessarily want to learn SAS programming, then this book was written for you! ![]() Efficient Data Access with SAS Enterprise Guide (YouTube) -- Shows the best way to access data in a DBMS from SAS Enterprise Guide, using M&Ms as a prop. ![]() Exciting combinations: SAS and Microsoft Office (YouTube) -- A metaphor for the exciting features you get when you add the SAS Add-In for Microsoft Office to your desktop.
The blog content appearing on this site does not necessarily represent the opinions of SAS. Your use of this blog is governed by the Terms of Use.
|