GINSIDE Procedure

Example 1: Determining Values by Using the GINSIDE Procedure

Features:

ID statement

Sample library member: GINSIDE2
This example uses the GINSIDE procedure to determine the state and county for each pair of coordinates in the input data set.
PROC PRINT Results of Output Data Set shows the values of STATE and COUNTY for each observation in the input data set.
PROC PRINT Results of Output Data Set
site    STATE    COUNTY       x          y

 a        42       133     1.34451    0.69892
 b        54        27     1.36910    0.68351
 c        54        27     1.36854    0.68723
 d        42        21     1.37470    0.70922

Program

data gps;
  input longitude latitude site $;
  x=longitude*arcos(-1)/180;
  x=x*(-1);
  y=latitude*arcos(-1)/180;
datalines;
-77.0348 40.0454 a
-78.4437 39.1623 b
-78.4115 39.3751 c
-78.7646 40.6354 d
;
run;
proc ginside data=gps map=maps.counties out=gpscounties;
  id state county;
run;
proc sort data=gpscounties;
  by site;
run;

proc print data=gpscounties;
  var site state county x y;
run;

Program Description

Create the GPS data set. The X and Y variables are converted from decimal degrees to radians. The X variable is also multiplied by –1 to switch the coordinates from west longitude to east longitude, in order to match the values in the MAPS.COUNTIES data set.
data gps;
  input longitude latitude site $;
  x=longitude*arcos(-1)/180;
  x=x*(-1);
  y=latitude*arcos(-1)/180;
datalines;
-77.0348 40.0454 a
-78.4437 39.1623 b
-78.4115 39.3751 c
-78.7646 40.6354 d
;
run;
Determine the values of STATE and COUNTY for each data point.
proc ginside data=gps map=maps.counties out=gpscounties;
  id state county;
run;
Sort and print the output data set.
proc sort data=gpscounties;
  by site;
run;

proc print data=gpscounties;
  var site state county x y;
run;