Creating Custom Polygons

Overview of Creating Custom Polygons

Deploying custom polygons in SAS Visual Analytics involves a series of steps. A provided SAS program performs most of the steps, and only minor modifications are required in some circumstances. You might need to modify the code depending on the polygon data set used and the environment in which the code is executed.
Once the registration is done, the SAS Web Application Server requires a restart before the custom polygons are accessible in SAS Visual Analytics.
Note: Prior to any processing, you should create a backup of the ATTRLOOKUP and CENTLOOKUP tables. In the event of any unexpected results, you will then be able to restore the original tables.
Perform the following high-level steps to create custom polygons:
  1. Create the library that contains your custom polygon data sets. See MAPSCSTM Library.
  2. Obtain the polygon data that you want to add. The data must be in Esri shapefile file format.
  3. Download the custom polygon deployment program at support.sas.com/rnd/datavisualization/vageo/va74polygons.sas.
  4. In the custom polygon deployment program, define the library references and macro variables for your custom polygons.
  5. If necessary, modify the PROC SQL statement in step 2 of the custom polygon deployment program to ensure that the lookup values are unique.
  6. Run the custom polygon deployment program.
  7. Restart the web application server.

MAPSCSTM Library

Before you can create custom polygons, you must define a MAPSCSTM library to contain the custom polygon data sets. The recommended location for this library is at SASHOME/SASFoundation/9.4/mapscstm or within the same directory location as the default MAPSGFK library. Include a LIBNAME statement in your appserver_autoexec_usermods.sas file, located by default at config-dir/Lev1/SASApp that references this directory. If your SAS Visual Analytics deployment runs on multiple server contexts, then add the LIBNAME statement to the file for each server context.
After you have modified your autoexec file, restart the SAS Object Spawner.
Note: You must have Write permissions for the directory that contains the MAPSCSTM library to create the output polygon data sets.

Custom Polygon Deployment Program

Custom polygons can be deployed to SAS Visual Analytics by using a SAS program that is available at support.sas.com/rnd/datavisualization/vageo/va74polygons.sas. The example programs in this chapter also feature the custom polygon deployment program.
The first section of the SAS program sets the values of macro variables that specify the inputs and outputs of the program.
Specify the following macro variables:
REGION_SHP_FILE
specifies the name of the shapefile files on the server. PROC MAPIMPORT is later used to import the file into SAS.
REGION_SHP_ID_COL
specifies the column in the polygon data set that represents the unique ID of each polygon.
REGION_SHP_NAME_COL
specifies the column in the polygon data set that represents the name of each polygon.
REGION_SHP_DENSITY
specifies the coordinate density for the output polygon data. Specify a value between 1 (low) and 10 (high). Typically, a value of 5 or less is recommended for standard reporting. Higher density values generally decrease report-rendering performance and require more browser memory.
REGION_LABEL
specifies the label for the set of custom polygons that are being added. The label is used in SAS Visual Analytics to identify these custom polygons.
REGION_PREFIX
specifies a two-letter identifier for your custom polygon that is not previously used in the ATTRLOOKUP data set. If the identifier value is already in use, then the deployment program displays an error message.
REGION_ISO
specifies any numeric identifier, between 0 and 999 (inclusive) for your custom polygon that is not previously used in the ATTRLOOKUP data set. If the identifier value is already in use, then the deployment program displays an error message.
REGION_DATASET
specifies the location and name for the output polygon data set.
Tip
To read the contents of an Esri shapefile without ArcGIS software, use the MAPIMPORT procedure to read the shapefile into SAS, and then use the CONTENTS or PRINT procedure to view the data. For details, see MAPIMPORT in SAS/GRAPH: Mapping Reference.
Note: The MAPSCSTM library used for your polygon data set needs to be manually created. For more information, see MAPSCSTM Library.
You must also ensure that the values for IDLABEL (IDNAME) are unique. In step 2 of the deployment program, edit the PROC SQL statement if needed to make the values unique. For example, step 2 in Example 2: US Counties concatenates two columns from the shapefile to create unique values.

Output Data Sets

The successful completion of the program creates two data sets in the MAPSCSTM library and appends the necessary records to the ATTRLOOKUP and CENTLOOKUP tables.
The primary data set is specified by the REGION_DATASET macro variable in the polygon deployment program. For example, the primary data set from Example 1 is MAPSCSTM.DE_ZIP1. The primary data set contains all of the necessary ID variables and coordinate values that are necessary to generate the custom polygons.
The validation data set has the same name as the primary data set, with the string _VALIDATE appended to the end of the data set name. For example, the validation data set from Example 1 is MAPSCSTM.DE_ZIP1_VALIDATE. The validation data set contains a single observation for each polygon. It contains a value corresponding to the ID and IDNAME variable in the primary data set, as well as a randomly generated measure value. The validation data set can be used in SAS Visual Analytics to test and validate the generation of each individual polygon and the custom polygon data as a whole. See Testing Custom Polygons in SAS Visual Analytics.
Last updated: December 18, 2018