GPROJECT Procedure

Example 3: Clipping an Area from the Map

Features:
PROC GPROJECT options:
DATA= required argument
OUT= optional argument
LATLON
LONGMAX=
LONGMIN=
LATMAX=
LATMIN=

ID statement

PATTERN statement

PROC GMAP statement

CHORO statement

Data sets:MAPSGFK.US_STATES (input map data set for DATA step)

WORK.US48UNPROJ (input map data set of unprojected data)

GULF (input map data set and map data set)

Sample library member:GPJGCLIP
Notes:This example uses GfK GeoMarketing map data. If you want to use traditional map data, see Clipping an Area from the Map Using Traditional Map Data.
The SAS Sample Library is not available in SAS Studio.You can download the mapping samples in the SAS Sample Library in zipped format from the SAS/GRAPH Learning and Support page on support.sas.com. Click the link for SAS/GRAPH and Base SAS: Mapping Reference (Examples ZIP).
The map data set or data sets supplied by SAS and used in this program might not be an available resource on your system.

This example uses the clipping capabilities of PROC GPROJECT to create a map of the states in the United States that border the Gulf of Mexico. Because the PROJECT= option is not used in the GPROJECT procedure, the Albers' equal-area projection method is used by default.

Clipped map of the U.S. Showing Only States Bordering the Gulf of Mexico

Program

goptions reset=all border device=png;

data us48;
   set mapsgfk.us_states;
   if state not in (2 15 72);
run;

proc gproject data=us48
              latlon
              degrees eastlong
              out=gulf
              longmin=-98
              longmax=-81
              latmin=25
              latmax=33;
   where density<5;
   id state;
run;

title "Northern Gulf Coast";
pattern value=mempty color=blue;
proc gmap map=gulf data=gulf all;
   id state;
   choro state / statistic=first nolegend levels=1;
run;
quit;

goptions reset=all;

Program Description

Set the graphics environment.
goptions reset=all border device=png;
Create a reduced continental U.S. map data set that excludes Alaska, Hawaii, and Puerto Rico.
data us48;
   set mapsgfk.us_states;
   if state not in (2 15 72);
run;
Clip and project a rectangular subset of the map. The LATLON option specifies that the unprojected coordinate data in the LAT and LONG variables in the map data set are used instead of the Y and X variables. The LONGMIN= and LONGMAX= options specify the minimum and maximum longitudes to be included in the map projection. The LATMIN= and LATMAX= options specify the minimum and maximum latitudes to be included in the map projection.
proc gproject data=us48
              latlon
              degrees eastlong
              out=gulf
              longmin=-98
              longmax=-81
              latmin=25
              latmax=33;
   where density<5;
   id state;
run;
Define the title for the map.
title "Northern Gulf Coast";
Define the pattern characteristics.
pattern value=mempty color=blue;
Show the clipped map.The STATISTIC= option indicates that the GMAP procedure is to match and graph only the first observation from the GULF data set. The NOLEGEND option suppresses the automatic legend. The LEVELS= option specifies that one response level is graphed.
proc gmap map=gulf data=gulf all;
   id state;
   choro state / statistic=first nolegend levels=1;
run;
quit;
Reset the graphics environment.
goptions reset=all;
Last updated: May 15, 2025