Examples


The following examples illustrate major features of 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: GRMUSMAP

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 CBSTATES and MAPS.US data sets. Output 42.1 shows the variables that are present in the data set before using the GREMOVE procedure:

Output 42.1: The MAPS.US Data Set
start example
 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 
end example
 

And Figure 42.3 on page 1229 shows the map before processing:

click to expand
Figure 42.3: Map before Removing Borders (GRMUSMAP(a))

Output 42.2 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:

Output 42.2: The REMSTATE Data Set
start example
 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 
end example
 

Figure 42.4 on page 1230 shows the new map after PROC GREMOVE has removed interior state boundaries.

click to expand
Figure 42.4: Map after Removing Borders (GRMUSMAP(b))

Assign the libref and set the graphics environment. If the libref MAPS is already assigned, omit the LIBNAME statement.

 libname maps '  SAS-maps-library  ';  goptions reset=global gunit=pct border cback=white           colors=(black blue green red)           ftext=swiss htitle=6 htext=3; 

Create data set CBSTATES. This data set includes a variable, DIVISION, that contains the number of the U.S. Bureau of the Census division for the state. This data step converts letter codes to numeric FIPS codes that match those in the STATE variable of MAPS.US.

 data 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  ; 

Sort data set in FIPS-code order. Create a sorted data set, CBSORT. It can be properly match-merged with the MAPS.US map data set, which is already sorted in FIPS-code order.

 proc sort data=cbstates out=cbsort;     by state;  run; 

Add DIVISION variable to map data set by merging the CBSORT data set with MAPS.US. Create a new map data set, USCB, that contains all of the state boundary coordinates from the MAPS.US data set plus the added variable DIVISION.

 data uscb;     merge cbsort maps.us;     by state;  run; 

Sort data set in DIVISION order. Sort USCB by the DIVISION variable to create the DIVSTATE data set.

 proc sort data=uscb out=divstate;     by division;  run; 

Remove interior boundaries within divisions. BY specifies the variable, DIVISION, in the input map data set that identifies the new unit areas. ID specifies the variable, STATE, in the input map data set that identifies the current unit areas.

 proc gremove data=divstate out=remstate;     by division;     id state;  run; 

Define title and footnote for map.

 title 'U.S. State Map';  footnote j=r 'GRMUSMAP(a) '; 

Define pattern characteristics.

 pattern value=mempty repeat=48 color=blue; 

Show the original map.

 proc gmap map=maps.us data=maps.us all;     id state;     choro state / nolegend;  run; 

Define new title and footnote for map.

 title 'U.S. Census Division Map';  footnote j=r 'GRMUSMAP(b) '; 

Show the regional map. ID specifies the variable, DIVISION, that identifies the unit areas in the processed data set. CHORO specifies DIVISION as the response variable.

 proc gmap map=remstate data=remstate all;     id division;     choro division / nolegend;  run;  quit; 

Example 2: Creating an Outline Map of Africa

Procedure features:

  • PROC GREMOVE options:

    • DATA=

    • OUT=

Other features:

  • GMAP procedure

Sample library member: GRMAFRIC

This example processes the MAPS.AFRICA map data set, supplied with SAS/ GRAPH, to produce a new map data set that contains no internal boundaries. This is done by adding a new variable, REGION, to the map data set and setting it equal to 1. Unit areas from the input map data set that have the same BY-variable value are combined into one unit area in the output map data set. Output 42.3 shows the variables present in the original map data set:

Output 42.3: The MAPS.AFRICA Data Set
start example
 MAPS.AFRICA Data Set   OBS    ID    SEGMENT       X         Y     1   125       1       0.57679   1.43730     2   125       1       0.57668   1.43467     3   125       1       0.58515   1.42363     .     .     .  3462   990       1       1.04249   0.50398  3463   990       1       1.04184   0.50713  3464   990       1       1.04286   0.50841 
end example
 

Figure 42.5 on page 1233 shows the map before processing:

click to expand
Figure 42.5: Map before Removing Borders (GRMAFRIC(a))

The new AFRICA map data set is created with a new variable, REGION. Output 42.4 shows the variables that are present in the new map data set created by the GREMOVE procedure:

Output 42.4: The AFRICA Data Set
start example
 AFRICA Data Set  OBS      X          Y       SEGMENT   REGION    1   0.24826    1.02167       1         1    2   0.25707    1.02714       1         1    3   0.26553    1.03752       1         1    .    .    .  982   1.19071    1.30043       3         1  983   1.18675    1.30842       3         1  984   1.18518    1.32822       3         1 
end example
 

Figure 42.6 on page 1234 shows the new map after PROC GREMOVE has removed all of the interior boundaries:

click to expand
Figure 42.6: Map after Removing Borders (GRMAFRIC(b))

Assign the libref and set the graphics environment.

 libname maps '  SAS-maps-library  ';  goptions reset=global gunit=pct border cback=white           colors=(black blue green red)           ftext=swiss htitle=6 htext=3; 

Create the NEWAF data set. This new map data set contains all the variables in the SAS/ GRAPH supplied MAPS.AFRICA map data set plus the added variable REGION.

 data newaf;     set maps.africa;     region=1;  run; 

Remove the unit areas from the AFRICA data set. DATA= specifies the input map data set and OUT= specifies the output map data set. The input map data set has a variable called REGION that is used as the BY-variable to identify the new unit areas. The ID statement specifies the current unit areas from the input map data set.

 proc gremove data=newaf out=africa;     by region;     id id;  run; 

Define the title and footnote.

 title 'Africa with Boundaries';  footnote j=r 'GRMAFRIC(a) '; 

Define pattern characteristics.

 pattern value=mempty r=50 color=blue; 

Display the original map.

 proc gmap map=maps.africa data=maps.africa all;     id id;     choro id / nolegend;  run; 

Define a new title and footnote for the map.

 title 'Africa without Boundaries';  footnote j=r 'GRMAFRIC(b) '; 

Display the map with no boundaries. ID specifies the variable, REGION, that identifies the unit areas in the processed data set.

 proc gmap data=africa map=africa;     id region;     choro region / nolegend;  run;  quit; 



SAS.GRAPH 9.1 Reference, Volumes I and II
SAS.GRAPH 9.1 Reference, Volumes I and II
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 342

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net