Last active
July 11, 2017 07:55
-
-
Save ymattu/14c57400ca1814b3973cda8035bc856b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data foo; | |
input customer_number lat long; | |
datalines; | |
1 35.039200 135.728965 | |
2 35.626065 139.884678 | |
; | |
run; | |
/* 緯度経度、shapefileの全組み合わせを取ってくる */ | |
proc sql; | |
create table pairs as | |
select unique a.*, b.x, b.y, b.N03_001, b.N03_003, b.N03_004 | |
from foo a, map.japanshp b | |
where b.x^=. and b.y^=.; | |
quit; run; | |
/* 緯度経度とshapeflieデータの距離を求める */ | |
data pairs; set pairs; | |
distance = geodist(lat, long, y, x, 'DM'); | |
run; | |
/* 一番近い距離のデータを取ってくる */ | |
proc sort data=pairs out=pairs; | |
by customer_number distance; | |
run; | |
data pairs2; | |
set pairs (keep = customer_number lat long N03_001 N03_003 N03_004); | |
by customer_number; | |
if first.customer_number then output; | |
run; | |
proc print data=pairs2;run; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment