Graphics
205
USING SAS/GRAPH FOR MAPPING PHYSICAL FEATURES
THROUGHOUT THE UNITED STATES
Mitchell B. Karpman
United States General Accounting Office
INTRODUCTION
The United States General Accounting
Office is a legislative agency whose mission
includes responding to congressional requests.
Requests are typically submitted by congressional
committees or directly from one or several
Members of Congress. GAO fulfills these requests
through oral briefings to Members and their staff,
testimony or reports. Because GAO often
presents spatial information, our agency is
becoming increasingly aware of the benefits of
displaying data spatially and the usefulness of
geographic information systems. The purpose of
this paper is to discuss (1) the use of a commonly
available data source known as Digital Une Graph
(DLG) data in PROC GMAP and (2)
enhancements to the DLG data file from various
federal agencies.
For those who are interested in SAS's
upcoming GIS package, much of what is
discussed in this paper may be included in the
experimental or future releases of SAS/GIS.
However, for those who cannot utilize SAS/GIS,
this paper will offer an alternative. Also a new
version of the DLG file is being developed, known
as DLG-E (extended).
OVERVIEW OF WHAT CAN BE PORTRAYED
USING DLG DATA
The Digital Une Graph (DLG) data from
the Department of Interior's U.S. Geologic Survey
has received widespread attention in recent years
among analysts portraying information about the
United States spatially. DLG is available in a
number of resolutions from small scale
1 :2,000,000 (1 inch is approximately 32 miles)
through large scale 1:24,000 resolution (1 inch is
apprOximately 2,000 feet). The discussion in this
paper is limited to the 1:2,000,000 DLG resolution.
DLG presents spatial addresses or geographic
coordinates on 1) political boundaries for units
such as states and counties, 2) administrative
boundaries such as Indian reservations, fish and
wildlife refuges, parks, forests, 3) cultural features
such as airports (both civilian and military) and
pipelines, 4) water bodies, such as lakes, 5) rivers
of varying sizes, 6) roads of varying sizes, and 7)
railroads. While the magnetic data tape for DLG
is over $1,000, the same data on one CD-ROM
costs only $32.
APPROACH
The approach outlined in this paper is to
include a SAS map data set as one layer of
boundary information, via PROC GMAP and then
use the DLG data as an annotate data set. To
use a SAS map data set and an annotate data set
based on the DLG data within PROC GMAP, both
files must be processed in common coordinates.
REVIEW OF PROC GMAP
The code for SAS/PC 6.04 for displaying
the map of the United States would be (see
Figure 1) LlBNAME MAPS 'C:\SAS\MAPS';
PATTERN V=E;
PROC GMAP DATA=MAPS.US MAP=MAPS.US;
10 STATE;
CHORO STATE / NOLEGEND LEVELS=1;
For more information on SAS map data sets, see
SAS Technical Report P-l96 entitled SAS/GRAPH
Software: Map Data Sets.
CONVERTING SAS MAP DATA SETS TO
DECIMAL DEGREES
All points on the earth's surface can be
expressed in latitude and longitude. Often these
NESUG '92 proceedings
206
Graphics
coordinates are measured in degrees, minutes
and seconds and transformed to decimal degrees.
An example of both units of measurements -Latitude (DDMMSS)
DATA COUNTY; SET MAPS. COUNTY;
* subsets only the Northeastem states;
IF (FIPSTATE(STATE» IN
"NY' 'CT' 'NH' 'RI' 'VT' 'ME' 'MA')·
COUNTY = (STATE*100) + COUNTY;
\
=
Degrees (DO)
Minutes (MM)
Seconds (SS)
Latitude (decimal degrees) =
DO + MM/60 + SS/3600
Figure 2 displays coordinates (decimal degrees)
which illustrate the four quadrants of the earth.
Decimal degrees are known as
un projected coordinates. Unprojected
coordinates which are based on a spherical
system must be transformed via PROC
GPROJECT into a coordinate system that is twodimensional for use in PROC GPLOT or PROC
GMAP. SAS includes map data sets whose
coordinates are projected (such as US and
USCOUNTY), unprojected such as COUNTY, and
both unprojected and projected (such as USCITY
and USCENTER). Note that SAS stores the
unprojected coordinates not in degrees but in
radians. The follOWing expression transforms
decimal degrees into radians.
Radians=decimal degrees*(ATAN(1)/45);
SAS expects that both the ANNOTATE
and map unprojected data sets are
simultaneously used in PROC GPROJECT and the
resultant data sets passed to PROC GMAP.
Therefore the user must ensure that both data
sets are initially un projected and in the same
metric (i.e. both data sets in radians) and then
simultaneously entered into PROC GPROJECT.
REMOVING COUNTY BORDERS FOR MORE
ACCURATE STATE MAPS
The following code uses the Northeast
portion of the COUNTY data set and removes
county borders to portray only the state borders
(see Figure 3).
UBNAME MAPS 'C:\SAS\MAPS';
PATTERN V=E;
NESUG '92 Proceedings
'
t
,
,
,
,
,
*removes county borders;
PROC GREMOVE DATA = COUNTY
OUT = NECOUNTY;
10 COUNTY;
BY STATE;
*creates data set NESTATE;
PROC GPROJECT DATA=NECOUNTY
OUT = NESTATE;
ID STATE;
PROC GMAP DATA=NESTATE MAP=NESTATE;
10 STATE;
CHORO STATE / LEVELS=1 NOLEGEND;
PROCESSING DLG DATA INTO A SAS
ANNOTATE DATA SET
DLG data is separated into 21 sections
composing the United States, the first 15 sections
portray the continental United States. For
instance, the Northeast United States which is
considered Section 1, contains Conneticut, New
Hampshire, Maine, Rhode Island, New York,
Massachusetts and Vermont Within each section
three different files are available to users of DLG
data. Two of the data files are projected and are
known as the standard and optional formats. The
third data file contains unprojected coordinates
and is known as the graphic format. For each of
the 21 sections and 3 formats there are 6 physical
features discussed earlier - political boundaries
(I.e. state and county borders), administrative
boundaries (borders of Indian reservations, fish
and wildlife refuges), rivers, roads, railroads,
airports (airports are not available in the graphic
format).
USING THE GRAPHIC FORMAT DLG DATA
The following code 1) produces an
ANNOTATE data set named DLGANN01 using
the MOVE and DRAW FUNCTIONS from the
graphic format for roads for the states of New
York, Conneticut, Massachusetts, Maine, Rhode
Graphics
Island, Vermont and New Hampshire, 2) appends
DLGANNO and NESTATE as input into PAOC
GPAOJECT, 3) uses PAOC GMAP on the
projected NESTATE data set and the annotated
DLG Interstate data set-DLGANN01.
FILENAME OAIG 'SOl AD. GAP;
FILENAME NEW 'SOl':-RD.DAT';
*reads in graphic DLG file and produces new
data file;
DATA NULL; INFILE ORIG RECFM=N;
FILE New; LENGTH READ $20.;
INPUT READ $CHAR20.;
PUT READ $CHAR20.:
*creates ANNOTATE data set = DLGANN01:
DATA DLGANN01; INFILE NEW;
DROP
LATDD LATDM LATDS LONGDD LONGDM
LONGDS 11 12:
raw
207
X=
(LONGDD+ (LONGDM/60) + (LONGDS/3600» *
(ATAN(l)/45);
*uses only Interstates:
IF FlVE=29050 & RANK=l THEN OUTPUT;
END;
DATA NECOUNTY; SET MAPS.COUNTY:
S=FIPSTATE(STATE);
IF S IN ('NY','CT','NH','RI', 'VT':ME':MA');
COUNTY=(STATE*100) + COUNTY:
PROC GREMOVE DATA=NECOUNTY
OUT=NESTATE;
BY STATE;
10 COUNTY;
*appends both data sets;
DATA BOTH: SET NESTATE DLGANN01:
*simultaneously projects both data sets;
PROC GPROJECT DATA=BOTH OUT=BOTH:
10 STATE;
LENGTH COLOR FUNCTION $8 WHEN $1:
*separates data sets in map and annotate data
RETAIN
TYPEUNE RANK NP FIVE XSYS YSYS
WHEN COLOR STATE:
XSYS='2'; YSYS='2':
WHEN='A';
COLOR = 'RED';
STATE=-l;
INPUT
TYPEUNE $ 1-7 RANK 8-9
NP 10-15 FIVE $ 16-20;
sets;
DATA NESTATE DLGANN01; SET BOTH:
IF STATE <0 THEN OUTPUT DLGANN01;
ELSE OUTPUT NESTATE;
PATTERN V=E:
PROC GMAP DATA=NESTATE MAP=NESTATE;
10 STATE;
CHORO STATE / LEVELS = 1 NOLEGEND
ANNOTATE=DLGANN01; RUN;
USING THE OPTIONAL DLG FORMAT DATA
DO 1=1 TO NP;
IF 1=1 THEN FUNCTION='MOVE';
ELSE FUNCTION = 'DRAW';
INPUT LATDD 1-2 LATDM 3-4
LATDS 5-6 11 $ 7
LONGDD 8-10 LONGDM 11-12
LONGDS 13-1412 $ 15 SEa 16-20;
*create radians from decimal degrees;
Y=
(LATDD+(LATDM/60)+(LATDS/3600» *
(ATAN(1)/45);
While the graphic format data set is
unprojected, it does not include any attributes
such as Interstate number (for the case of roads).
The standard or optional DLG format does offer
this information. However, the standard and
optional formats are projected and must be
unprojected first if they are to be used
simultaneously with a SAS map data set. Thus,
the user must invert or transform the projected
coordinates back to the original unprojected
coordinates.
NESUG
192
Proceedings
208
Graphics
The following code 1) takes an altered
optional DLG data file that has unprojected
coordinates and produces a SAS annotate data
set named DLGANN02 using the SYMBOL
FUNCTION of civnian airports for the states of
New York, Conneticut, Maine, Massachusetts,
Rhode Island, Vermont and New Hampshire, 2)
appends DLGANN02 and NESTATE as input into
PROC GPROJECT, 3) uses PROC GMAP on the
projected NESTATE data set and the annotated
DLG airport data base-DLGANN02 (see Figure 4).
SUMMARY
The DLG data offers an opportunity to
portray a variety of physical features and is a rich
source of spatial information for a SAS
ANNOTATE data set. For physical features in
DLG such as airports, the SAS FUNCTION POINT
or SYMBOL could be used. For physical features
that are areas such as Indian reservations wildlife
refuges, parks and forests, the SAS FUNCTION
POLY and POLYCONT could be used. In
addition, the use of the GRAPHICS EDITOR in
SAS 6.07 will enhance the ways that analysts can
annotate information from SAS/GRAPH.
Primarily because the DLG is limited in
attribute information, various federal agencies
have developed data bases that serve as
enhanced DLG digital data. For instance, the
Department of Transportation's Federal Highway
Administration has created a digital data base with
390,000 miles of highways and over a dozen
attributes. These attributes include up to three (3)
route identifiers, toll information, and truck routes.
In addition, the Department of Transportation
developed digital data on bridges and airports.
An example of the Interstate highway network in
the Northeast is displayed in Figure 5.
The federal sector has been the prime
source of digital data and as the exchange of
spatial data such as TIGER/Une and DLG data
expands, it is reasonable to expect that analysts
using SAS will increase their use and demand for
spatially referenced data sets.
NESUG '92 proceedings
Graphics
209
LlBNAME C 'C:\';
%MACRO AIRPORT (IN=IN,OUTSSD=OUTSSD);
DATA AREAS (KEEP=AREA LINE)
LINES (KEEP=LlNE X y)
AREAATR (KEEP=AREA AREAMAJl AREAMIN1 AREAMAJ2 AREAMIN2)
LlNEATR (KEEP=LlNE LlNEMAJ1 UNEMINl LlNEMAJ2 LlNEMIN2);
INFILE &IN LRECL=80 MISSOVER;
INPUT #4 NUMN 55-60 NUMQ 61-66 #10 DUMMY1 $ 1;
DO 1=1 TO NUMN; INPUT; END;
INPUT NUMNODES 31-36 NUMAREAS 47-52 NUMLINES 63-68;
DO J=l TO NUMNODES;
. INPUT DUMN $ 1 COUNTN COORDN1 COORDN2 NCOL42 NC0154 BLANKN1;
IF NCOL42>O THEN INPUT; IF NC0L54>O THEN INPUT;
END;
DO J=l TO NUMAREAS;
INPUT DUMA $1 AREA COORDA1 COORDA2 ACOL42 DUMA1 AC0L54 DUMA2 DUMMA3;
IF ACOL42>O THEN DO;
DO JJ=l TO «INT(ACOL42-1)/12) + 1);
INPUT UNE1-LlNE12;
ARRAY LlNEM (12) LlNE1-LlNE12;
DO M=l TO 12;
LlNEM(M) =ABS(LlNEM(M»;
IF LlNEM(M) NE . THEN DO;
UNE=LlNEM(M); OUTPUT AREAS;
END;
END;
END;
END;
IF AC0154>O THEN DO;
DO JJJ=l TO «INT(AC0L54-1)/12) +1);
INPUT AREAMAJ1 AREAMINl AREAMAJ2 AREAMIN2; OUTPUT AREAATR;
END;
END;
END;
DO K= 1 TO NUMLINES;
INPUT DUML $ 1 COUNTl START1 START2 LEFTAREA RIGHAREA NUMBER NUMPAIR;
NUMREC= (NUMBER-l) /3; NUMREC= (INT(NUMREC» + 1;
DO L=l TO NUMREC;
INPUT Xl Y1 X2 Y2 X3 Y3;
IF Xl NE. THEN DO; LlNE=COUNTL; X=X1; Y=Y1; OUTPUT LINES;
END;
END;
IF NUMPAIR>O THEN DO;
NESUG '92 proceedings
210
Graphics
DO JJJJ=1 TO ((INT(NUMPAIR-1)/12) +1);
INPUT UNEMAJ1 LlNEMIN1 UNEMAJ2 LlNEMIN2;
IF LlNEMAJ1 NE . & LlNEMIN1 NE . THEN OUTPUT LlNEATR;
END;
END;
END;
DATA LlNEATR; SET UNEATR; IF (LINEMIN1 =7001);
"brings in only civilian airports;
DATA &OUTSSD; *gets LINES and LlNEATR to merge by LINE;
MERGE UNES (IN=INL) LlNEATR (IN=INA); BY LINE; IF INA;
%MEND AIRPORT;
********************************************************.,
AIRPORT (IN='S01 CF.LLL',OUTSSD=C.AIRPORTS); RUN;
********************************************************.,
DATA DLGANN02; SET C.AIRPORTS;
LENGTH COLOR FUNCTION $ 8 WHEN $ 1;
RETAIN XSYS YSYS WHEN COLOR;
RETAIN SIZE 2;
XSYS='2'; YSYS='2';
WHEN = 'A';
COLOR = 'RED';
TEXT='C';
STYLE = 'CARTOG';
X= (-1)*X*(ATAN(1)/45);
Y=Y*(ATAN(1)/45);
FUNCTION = 'SYMBOL';
STATE =-1;
DATA NECOUNTY; SET MAPS. COUNTY;
S=FIPSTATE(STATE);
IF S IN ('NY','cr,'NH','RI','vr','ME','MA');
COUNTY = (STATE" 1000) + COUNTY;
PROC GREMOVE DATA=NECOUNTY OUT=NESTATE; BY STATE; ID COUNTY;
DATA BOTH; SET NESTATE DLGANN02;
PROC GPROJECT DATA=BOTH OUT=BOTH; ID STATE;
DATA NESTATE DLGANN02; SET BOTH;
IF STATE <0 THEN OUTPUT DLGANN02; ELSE OUTPUT NESTATE;
PATTERN V=E;
SYMBOL W=3 L=1;
PROC GMAP DATA=NESTATE MAP=NESTATE; ID STATE;
CHORO STATE / LEVELS = 1 NOLEGEND ANNOTATE=DLGANN02; RUN;
NESUG
192
Proceedings
© Copyright 2026 Paperzz