Before we start calculating the distance between the store and the customer's address, let's check if there are any missing coordinates in the SALES_Q1_LOC_POS table.
keep customer_postcode store_postcode store_x store_y cust_x cust_y;
Did the code fail because the input data sets don't exist?
Copy and run the code below to create the input data sets.
proc import datafile = "/folders/myfolders/Geo-targeting/Data Files/locations.csv"
out = locations
dbms = CSV
proc import datafile = "/folders/myfolders/Geo-targeting/Data Files/postcode.csv"
out = postcode
dbms = CSV
create table sales_q1_loc as
select a.*, b.os_x as store_x, b.os_y as store_y
from sales_q1 a, locations b
where a.store_postcode = b.postcode;
create table sales_q1_loc_pos as
select a.*, b.os_x as cust_x, b.os_y as cust_y
from sales_q1_loc a left join postcode b
on a.customer_postcode = b.postcode;
The data step above checks if there are any missing coordinates.
It turns out there are more than 9000 records that are missing the CUST_X and CUST_Y coordinates.
Can you figure out why these coordinates are missing?
Username or Email Address
Registration confirmation will be emailed to you.