<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Using SAS to Read the White House Visitors Log and Other Socrata-Hosted Datasets in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Using-SAS-to-Read-the-White-House-Visitors-Log-and-Other-Socrata/m-p/241626#M44793</link>
    <description>&lt;P&gt;This is excellent&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4628"&gt;@tc﻿&lt;/a&gt;! Thanks for sharing!&lt;/P&gt;</description>
    <pubDate>Mon, 04 Jan 2016 12:50:10 GMT</pubDate>
    <dc:creator>ChrisHemedinger</dc:creator>
    <dc:date>2016-01-04T12:50:10Z</dc:date>
    <item>
      <title>Using SAS to Read the White House Visitors Log and Other Socrata-Hosted Datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-SAS-to-Read-the-White-House-Visitors-Log-and-Other-Socrata/m-p/241557#M44773</link>
      <description>&lt;P&gt;In &lt;A href="https://dev.socrata.com/consumers/examples/analyzing-open-data-with-sas.html" target="_self"&gt;Analyzing Open Data with SAS&lt;/A&gt;, Socrata's Mark Silverberg explains how to use SAS code and the &lt;A href="https://dev.socrata.com/" target="_self"&gt;Socrata API&lt;/A&gt; to consume a Socrata-hosted open data dataset (the CDC's Behavioral Risk Factor Surveillance System health survey data).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There's a wealth of &lt;A href="https://opendata.socrata.com/" target="_self"&gt;Socrata-hosted datasets&lt;/A&gt; available on the web, including the &lt;A href="https://www.whitehouse.gov/briefing-room/disclosures/visitor-records" target="_self"&gt;White House Visitors Log&lt;/A&gt;. Below is a little SAS code that retrieves data from the WH Visitors Log. Plug in the name of your favorite public figure - the example uses Oprah - and see not only when they visited, but also with whom they met. Sure beats&amp;nbsp;having to download 100+ MB of zipped .csv files!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;*==&amp;gt; 1. Run request to retrieve White House Visitor Log meeting IDs (UINs) from Socrata;

filename whquery url 'http://open.whitehouse.gov/resource/p86s-ychb.csv?namelast=winfrey&amp;amp;namefirst=oprah&amp;amp;$limit=30000';

data whmeetings;
infile whquery dsd dlm=',' lrecl=2000 truncover firstobs=2; 
input NAMELAST : $30. NAMEFIRST : $30. NAMEMID : $30. UIN : $30. BDGNBR : $30. 
      Type_of_Access : $30. TOA : ANYDTDTM40. POA : $30. TOD : ANYDTDTM40. 
      POD : $30. APPT_MADE_DATE : ANYDTDTM40. APPT_START_DATE : ANYDTDTM40. 
      APPT_END_DATE : ANYDTDTM40. APPT_CANCEL_DATE : ANYDTDTM40. Total_People 
      LAST_UPDATEDBY : $30. POST : $30. LastEntryDate : ANYDTDTM40. 
      TERMINAL_SUFFIX : $30. visitee_namelast : $30. visitee_namefirst : $30. 
      MEETING_LOC : $30. MEETING_ROOM : $30. CALLER_NAME_LAST : $30. 
      CALLER_NAME_FIRST : $30. CALLER_ROOM : $30. Description : $255.
      RELEASE_DATE : MMDDYY10.;
FORMAT TOA TOD APPT_MADE_DATE APPT_START_DATE APPT_END_DATE APPT_CANCEL_DATE
       LastEntryDate DATETIME16. RELEASE_DATE MMDDYY10.;

proc sort data=whmeetings nodupkey; by uin;  * De-dupe;

*==&amp;gt; 2. Run request to retrieve meeting attendees from Socrata;

filename whquery2 url 'http://www.google.com';  * Placeholder URL initially;

data whattendees;
length whquery2 $255.;                     * Drop observations with no appointment ID;
set whmeetings(keep=UIN rename=(uin=inuin) where=(inuin^='')); 
whquery2="http://open.whitehouse.gov/resource/p86s-ychb.csv?UIN="||trim(inuin);
do while(^eof);
  infile whquery2 url filevar=whquery2  dsd dlm=',' lrecl=2000 truncover firstobs=2 end=eof;
  input NAMELAST : $30. NAMEFIRST : $30. NAMEMID : $30. UIN : $30. BDGNBR : $30. 
        Type_of_Access : $30. TOA : ANYDTDTM40. POA : $30. TOD : ANYDTDTM40. 
        POD : $30. APPT_MADE_DATE : ANYDTDTM40. APPT_START_DATE : ANYDTDTM40. 
        APPT_END_DATE : ANYDTDTM40. APPT_CANCEL_DATE : ANYDTDTM40. Total_People 
        LAST_UPDATEDBY : $30. POST : $30. LastEntryDate : ANYDTDTM40. 
        TERMINAL_SUFFIX : $30. visitee_namelast : $30. visitee_namefirst : $30. 
        MEETING_LOC : $30. MEETING_ROOM : $30. CALLER_NAME_LAST : $30. 
        CALLER_NAME_FIRST : $30. CALLER_ROOM : $30. Description : $255.
        RELEASE_DATE : MMDDYY10.;
  output;
end;
eof=0; 
FORMAT TOA TOD APPT_MADE_DATE APPT_START_DATE APPT_END_DATE APPT_CANCEL_DATE
       LastEntryDate DATETIME16. RELEASE_DATE MMDDYY10.;

*==&amp;gt; 3. UINs are reused, so only select matches on UIN &amp;amp; appointment start time;

proc sql;
create table whmeetingattendees as select a.* from whmeetings m 
left join whattendees a on m.uin=a.uin and m.APPT_START_DATE=a.APPT_START_DATE
order by a.APPT_START_DATE, uin, namelast, namefirst;

*==&amp;gt; 4. Export results to Excel;

proc export data=whmeetingattendees
            outfile='/folders/myfolders/whmeetingattendees.xlsx' dbms=xlsx replace;
sheet="whmeetingattendees";

proc sort data=whmeetings; by APPT_START_DATE uin;
proc export data=whmeetings
            outfile='/folders/myfolders/whmeetingattendees.xlsx' dbms=xlsx replace;
sheet="whmeetings";
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/1348i92F6B8B290A027CF/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="WhVisitorsLog.jpg" title="WhVisitorsLog.jpg" /&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 03 Jan 2016 16:32:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-SAS-to-Read-the-White-House-Visitors-Log-and-Other-Socrata/m-p/241557#M44773</guid>
      <dc:creator>tc</dc:creator>
      <dc:date>2016-01-03T16:32:30Z</dc:date>
    </item>
    <item>
      <title>Re: Using SAS to Read the White House Visitors Log and Other Socrata-Hosted Datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-SAS-to-Read-the-White-House-Visitors-Log-and-Other-Socrata/m-p/241626#M44793</link>
      <description>&lt;P&gt;This is excellent&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4628"&gt;@tc﻿&lt;/a&gt;! Thanks for sharing!&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jan 2016 12:50:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-SAS-to-Read-the-White-House-Visitors-Log-and-Other-Socrata/m-p/241626#M44793</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2016-01-04T12:50:10Z</dc:date>
    </item>
  </channel>
</rss>

