SASGRAPH Map Data Sets Reference Information


SAS/GRAPH Map Data Sets Reference Information

Before using your map data sets, contact your SAS Support Consultant to verify the name and location of the SAS data library that contains the map data sets at your site. Many sites automatically assign a libref of MAPS to the SAS data library that contains the SAS-supplied map data sets. However, if you use the map data sets regularly and your site does not automatically assign a libref to the data library that contains the map data sets, you can add a LIBNAME statement to your AUTOEXEC file that defines the location of the map data set library. If you do this, the libref for the maps is established automatically whenever you begin a SAS session.

Accessing Detailed Descriptions of Map Data Sets

You may need detailed information on the map data sets in order to determine their type, size , the variables they contain, or, in the case of traditional data sets, whether they are projected or unprojected. You can get this information by using the CONTENTS or DATASETS procedure, or browsing the MAPS.METAMAPS (see Viewing Map Data Sets on page 1001) data set in the MAPS library (or the library where your SAS-supplied map data sets reside). If the libref MAPS has automatically been assigned, you can see a complete list of map data sets by viewing the MAPS.METAMAPS data set. See

These statements list the map data sets in the SAS data library that is assigned to the libref MAPS:

 libname maps '  SAS-data-library  ';  proc datasets lib=maps;  run; 

Note: Be sure to replace SAS-data-library with the location of the SAS data library that contains map data sets at your site.

The following statements provide detailed information on a traditional map data set, including the number of observations, the variables in each data set, and a description of each variable:

 libname maps '  SAS-data-library  ';  proc contents data=maps.canada3;  run; 

To see the contents and descriptions of all of the SAS-supplied map data sets you can specify DATA=MAPS._ALL_ in the CONTENTS procedure. See the Base SAS Procedures Guide for more information on the CONTENTS and DATASETS procedures.

Customizing SAS/GRAPH Map Data Sets

You can customize the area that is displayed on your map by using only part of a particular map data set. There are several ways to accomplish this. You can use WHERE processing or a DATA step to subset the map data to be used by the GMAP procedure.

With the traditional map data set, you can also use the GPROJECT procedure to create a rectangular subset of a map data set by using minimum and maximum longitude and latitude values.

You can combine traditional map data sets in either of these situations:

  • The map data sets to be combined were originally projected together.

  • The map data sets all contain the same type of coordinates. That is, all are in radians or all are in degrees.

SAS-supplied traditional map data sets that have coordinates expressed only as longitude and latitude, with variable names LONG and LAT, must be renamed X and Y and should be projected before displaying.

Subsetting Traditional Map Data Sets

Some of the SAS/GRAPH map data sets contain a large number of observations. Programs that use only a few states or provinces will run faster if you exclude the unused portion of the map data set or use an already reduced map data set. SAS provides several ways to accomplish this. One is to use the WHERE statement or WHERE= data set option within the GMAP procedure to select only the states or provinces you want.

The WHERE statement and WHERE= data set option are most useful when you produce a simple map and do not need to make any other changes to the data set. For example, to use only the observations for Quebec in the CANADA traditional map data set, begin the GMAP procedure with this statement:

 proc gmap map=maps.canada(where=(province=24)); 

To use only North Carolina in US2MERGED, a data set created by using SQL or DATA step MERGE on the feature table US2 and a response data set also containing the variable STATE, the GMAP procedure would begin with the following statement:

 proc gmap data=work.us2merged(where=(STATE=37)); 

The WHERE= data set option applies only to the data set that you specify in the argument in which the WHERE= option appears. If you use the WHERE statement, the WHERE condition applies to the traditional map data set and the response data sets or the merged response and feature table.

Another approach is to use a DATA step to create a subset of the larger data set. This code illustrates another way to extract the observations for Quebec from the CANADA traditional map data set:

 data quebec;     set maps.canada(where=(province=24)); 

This code illustrates another way to extract North Carolina data from the US2 feature table:

 data ncarolina;     set maps.us2(where=(STATE=37)); 

This approach is most useful when you want to create a permanent subset of a map data set or when you need to make additional changes to the map data set.

Also see Chapter 42, The GREMOVE Procedure, on page 1223 for an example how to use GREMOVE to create a regional map from one of the traditional map data sets that are supplied with SAS/GRAPH.

Reducing Traditional Map Data Sets

A reduced map data set is one that can be used to draw a map that retains the overall appearance of the original map but that contains fewer points, requires considerably less storage space, and can be drawn much more quickly. You can improve performance by plotting fewer observations for each map area. You reduce a traditional map data set when you subset it on the variable DENSITY. You can add the variable DENSITY to a map data set by using the GREDUCE procedure. For more information, see Chapter 41, The GREDUCE Procedure, on page 1213.

An unreduced map data set contains all of the coordinates that were produced when the map was digitized. This type of map data set has more observations than most graphics output devices can accurately plot. Some unreduced map data sets already contain a DENSITY variable like the one calculated by the GREDUCE procedure, so it is not necessary to use the GREDUCE procedure to process these data sets. Values for DENSITY range from 0 through 6 (the lower the density, the coarser the boundary line).

A statement of this form excludes all points with a density level of 2 or greater:

 proc gmap map=maps.states(where=(density<2)); 

The resulting map is much coarser than one drawn by using all of the observations in the data set, but it is drawn much faster.

Another way to create a reduced map data set is to use a DATA step to exclude observations with larger density values:

 data states;     set maps.states(where=(density<2)); 

Projecting Traditional Map Data Sets

Map data can be stored as unprojected or projected coordinates. Unprojected map data contains spherical coordinates, that is, longitude and latitude values usually expressed in radians. [*]

Each of the feature tables in the MAPS library are projected. A few traditional map data sets that are provided with SAS/GRAPH contain only unprojected coordinates and should be projected before you use them. They are

  • CANADA3

  • CANADA4

  • COUNTIES

  • COUNTY

  • STATES

Projected map data contains Cartesian coordinates. The GMAP procedure is designed to plot maps by using projected map data sets. Feature tables store the projected data in the $GEOREF formatted variable (see $GEOREF format on page 1001). Most SAS/GRAPH traditional map data sets contain projected coordinates that are stored as X and Y.

If the projection supplied with the traditional map data set does not meet your needs, then you can use the GPROJECT procedure (on unprojected map coordinates) to create a different projection. For more information on traditional map data sets with unprojected coordinates, see Traditional Map Data Sets Containing X, Y, LONG, and LAT on page 1000. You should select a projection method that least distorts the regions that you are mapping. (All projection methods inherently distort map regions .) See Chapter 39, The GPROJECT Procedure, on page 1161 for more information.

Note: Using an unprojected traditional map data set with the GMAP procedure can cause your map to be reversed and distorted .

Controlling the Display of Lakes

Some countries contain a lake that is located completely within a single unit area. Occasionally these lakes can be a problem when mapping traditional map data sets. In addition, displaying lakes may not be appropriate for some applications. In these cases, you may want to remove the lakes from the map data set before you proceed.

Traditional map data sets that contain coordinates for a lake that is located within a single internal division are identified by the presence of the numeric variable LAKE. The value of LAKE is 1 for points that correspond to lakes and 0 otherwise . The following statements illustrate how to delete the lakes from your traditional map data sets using WHERE processing:

 proc gmap map=maps.chile(where=(lake=0))            data=maps.chile;     id id;     choro id / levels=1 nolegend;     title box=1 f=none h=4           'Chile with Lakes Removed';  run; 

You can also create a new traditional map data set that is a subset of the traditional map data set:

 data nolake;     set maps.chile;     if lake=0;  run; 

Creating Traditional Map Data Sets

In addition to using map data sets that are supplied with SAS/GRAPH software, you can also create your own map data sets. Map data sets are not limited to geographic data; you use them to define other spaces such as floor plans or street diagrams.

A unit area is defined by observations in the map data set that have the same identification (ID) variable value. A unit area may be composed of a single polygon or a collection of polygons. A polygon is defined by all of the observations that have the same SEGMENT variable value within the same unit area.

  • If the unit area is a single polygon, then all values of SEGMENT are the same.

  • If the unit area contains multiple polygons, such as islands, then the SEGMENT variable has multiple values. For example, in the MAPS.US data set, the state of Hawaii (a unit area) contains six different values in the SEGMENT variable, one for each island in the state.

  • If the unit area contains enclosed polygons, such as lakes, then the SEGMENT variable has one value but the interior polygon is defined by separate boundaries. To separate boundaries, a missing X and Y value must be inserted at the separation point. For example, in the CANADA2 data set supplied with SAS/ GRAPH, the map data for the Northwest Territories (a unit area) use enclosed polygons for two lakes.

Creating a Unit Area that is a Single Polygon

This DATA step creates a SAS data set that contains coordinates for a unit area with a single polygon, a square:

 data square;     input id x y;     datalines;  1 0 0  1 0 40  1 40 40  1 40 0  ; 

This data set does not have a SEGMENT variable.

Creating a Unit Area that Contains Multiple Polygons

Use different values of the SEGMENT variable to create separate polygons within a single unit area. For example, this DATA step assigns two values to the SEGMENT variable. The resulting data set produces a single unit area that contains two polygons, as shown in Figure 35.7 on page 1043:

 data map;     input id $ 1-8 segment x y;     datalines;  square 1 0 0  square 1 0 4  square 1 4 4  square 1 4 0  square 2 5 5  square 2 5 7  square 2 7 7  square 2 7 5  ; 
click to expand
Figure 35.7: Single Unit Area with Two Segments (Polygons)

Creating a Unit Area that Contains Enclosed Polygons as Holes

Use separate boundaries to create an enclosed polygon (that is, a polygon that falls within the primary polygon for a single segment). The separate boundaries are separated from the primary polygon boundary by missing values for X and Y. For example, the data set that is created by this DATA step produces the map shown in Figure 35.8 on page 1044:

 data map;     input id $ 1-8 segment x y;     datalines;  square 1 0 0  square 1 0 4  square 1 4 4  square 1 4 0  square 1 . .  square 1 1 1  square 1 2 2  square 1 3 1  ; 
click to expand
Figure 35.8: Single Unit Area with Hole

Creating a Unit Area that Contains Enclosed Polygons as Cities

Ordinarily, if one unit area is surrounded by another, the pattern of the external unit area is drawn over the pattern for the internal one, instead of around it. Avoid this problem by adding an observation to the map data for the external unit area with missing values for X and Y, followed by the coordinates of the internal unit area, but using the ID values for the external unit area. For example, this DATA step creates a data set that produces the map shown in Figure 35.9 on page 1045:

 data map;     input id $ 1-8 segment x y;     datalines;  square   1 0 0  square   1 0 4  square   1 4 4  square   1 4 0  square   1 . .  square   1 1 1  square   1 2 2  square   1 3 1  triangle 1 1 1  triangle 1 2 2  triangle 1 3 1  ; 
click to expand
Figure 35.9: Unit Area within a Unit Area

Note: A single map segment (a section of a unit area with a single value of the SEGMENT variable) cannot contain multiple polygons without at least one observation with missing values for X and Y. All segments within the map data sets that are supplied by SAS/GRAPH contain a single polygon that can have one or more separate boundaries, each separated by an observation with missing values for X and Y.

[*] If your data is in degrees, then it can be converted to radians by multiplying by the degree-to-radian constant [atan(1)/45].




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