Geo-targeting Project [20-25]

We will now generate the list of postcodes that are within 4.5 km of the three stores that we selected.

​The code below finds all the postcodes that are within 4.5 km of the stores:

proc sql;
create table target_postcode as
select a.*,
       round(((b.os_x - a.os_x)**2 + (b.os_y - a.os_y)**2) **0.5, 1) as dist
from all_postcode a, locations b
where b.postcode in
  (select store_postcode
   from target) and 
calculated dist <= 4500;
quit;

Did the code fail?

Copy and run the code below to create the input data sets.

There are 42408 postcodes that fall within the range of 4.5 km from the selected stores: