Skip to content

Instantly share code, notes, and snippets.

<?php
/* Create a curl file attachment for POSTing */
$cfile = curl_file_create('C:\Users\dbatten\Desktop\Addresses.csv');
/* Set up query parameters */
$post_options = array
(
'benchmark' => 'Public_AR_Current',
"3","200 North Blount Street, Raleigh, NC, 27601","Match","Exact","200 N BLOUNT ST, RALEIGH, NC, 27601","-78.63632,35.78259","72508526","R"
"2","129 West 81st Street, New York, NY, 10024","Match","Exact","129 W 81ST ST, NEW YORK, NY, 10024","-73.97544,40.783638","59656670","R"
"1","1600 Pennsylvania Avenue Northwest, Washington, DC, 20500","Match","Non_Exact","1600 PENNSYLVANIA AVE NW, WASHINGTON, DC, 20502","-77.03535,38.898754","76225813","L"
,AABEL,EVELYN,LARSEN,,W,NL,UNA,F,79
,AARON,CHRISTINA,CASTAGNA,,W,UN,UNA,F,38
,AARON,CLAUDIA,HAYDEN,,W,NL,UNA,F,69
,AARON,JAMES,MICHAEL,,W,UN,DEM,M,67
,AARON,NATHAN,EDWARD,,W,UN,UNA,M,38
create temp table voters (
name_prefix varchar(255),
last_name varchar(255),
first_name varchar(255),
middle_name varchar(255),
name_suffix varchar(255),
race char(1),
ethnicity varchar(255),
party char(3),
gender char(1),
create temp table
fullvoters
as select
*,
random() as split
from
voters
where
len(first_name) > 1
and len(middle_name) > 1
create temp table
train
as select
*
from
fullvoters
where
split >= .01;
create temp table
create temp table
first_scores
as select
first_name,
ln(cast(sum(case when t.gender = 'M' then 1 else 0 end) + 1 as float) / max(num)) as male_score,
ln(cast(sum(case when t.gender = 'F' then 1 else 0 end) + 1 as float) / max(num)) as female_score
from
train as t
left join
(
create temp table guesses as
select
t.first_name,
t.middle_name,
t.last_name,
t.name_suffix,
t.gender,
case when
case when f.male_score is null then 0 else f.male_score end + case when m.male_score is null then 0 else m.male_score end + case when s.male_score is null then 0 else s.male_score end
>
data lumber;
input @1 length 3. @5 price 8.2;
datalines;
72 2.50
96 3.50
120 5.00
run;
data cuts;
input @1 length 3. @5 number 3.;
/* Count the number of needed cut types and lumber types */
/* Save in macro variables */
proc sql;
select
count(*)
into
:num_cuts
from
cuts;