Chapter Contents

Previous

Next
The GREMOVE Procedure

Example 1: Removing State Boundaries from U.S. Map


Procedure features:
BY statement
ID statement
Other features:
SORT procedure
MERGE procedure
LIBNAME statement
Sample library member: GR25N01

This example processes the MAPS.US map data set, supplied with SAS/GRAPH, to produce a new map data set containing boundaries for the U.S. Bureau of the Census divisions. Because the MAPS.US map data set does not contain a variable to identify any unit area other than states, this example creates a map data set that contains the census divisions and that can be processed with the GREMOVE procedure.

The STATE variable in the MAPS.US data set, containing numeric FIPS codes for each state, is used as the BY-variable to merge the REFLIB.CBSTATES and MAPS.US data sets. The MAPS.US Data Set shows the variables that are present in the data set before using the GREMOVE procedure:

The MAPS.US Data Set
                              MAPS.US Data Set
               OBS    STATE    SEGMENT        X           Y

                 1      1          1       0.16175    -0.10044
                 2      1          1       0.12305    -0.10415
                 3      1          1       0.12296    -0.10678
                 .
                 .
                 .
              1524     56          1      -0.18757     0.15035
              1525     56          1      -0.10158     0.13997
              1526     56          1      -0.10398     0.11343

And Map before Removing Borders (GR25N01(a)) shows the map before processing:

Map before Removing Borders (GR25N01(a))

[IMAGE]

The REMSTATE Data Set shows the variables that are present in the data set after you use the GREMOVE procedure. Notice that the new map data set contains a new variable called DIVISION:

The REMSTATE Data Set
                          REMSTATE Data Set
              OBS       X          Y       SEGMENT    DIVISION

                1    0.29825    0.17418       1           1
                2    0.29814    0.17820       1           1
                3    0.30206    0.18045       1           1
                .
                .
                .
             1082   -0.18715   -0.16010       8           9
             1083   -0.18747   -0.15971       8           9
             1084   -0.18747   -0.15951       8           9

Map after Removing Borders (GR25N01(a)) shows the new map after PROC GREMOVE has removed interior state boundaries.

Map after Removing Borders (GR25N01(a))

[IMAGE]

 Note about code
libname reflib 'SAS-data-library';
libname maps 'SAS-maps-library';
goptions reset=global gunit=pct border cback=white
         colors=(black blue green red)
         ftext=swiss htitle=6 htext=3;
 Note about code
data reflib.cbstates;
   length state 8 stcode $ 2 division 4;
   input stcode division;
   state=stfips(stcode);
   drop stcode;
   datalines;
CT 1
MA 1
...more data lines...
OR 9
WA 9
;
 Note about code
proc sort data=reflib.cbstates out=cbsort;
   by state;
run;
 Note about code
data uscb;
   merge cbsort maps.us;
   by state;
run;
 Note about code
proc sort data=uscb out=divstate;
   by division;
run;
 Note about code
proc gremove data=divstate out=remstate;
   by division;
   id state;
run;
 Note about code
title 'U.S. State Map';
footnote j=r 'GR25N01(a) ';
 Note about code
pattern value=mempty repeat=48 color=blue;
 Note about code
proc gmap map=maps.us data=maps.us all;
   id state;
   choro state / nolegend;
run;
 Note about code
title 'U.S. Census Division Map';
footnote j=r 'GR25N01(b) ';
 Note about code
proc gmap map=remstate data=remstate all;
   id division;
   choro division / nolegend;
run;
quit;


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.