The Batch Import Process

Specifying Import Parameters

You specify the parameters for the import process by assigning values to macro variables or by assigning filerefs. The input parameters define the type of data to import, the location of the input spatial data, and other specifications for variables in your data set. Not all of the following parameters are necessary for all import types.
There are several ways to assign a value to a macro variable. These include using the %LET statement, using the SYMPUT SAS CALL routine in the DATA step, and using the SYMPUT or SYMPUTN functions in SAS Component Language (SCL). As long as the value that you want is stored in the macro variable along with the required name, it does not matter which method you use. However, all examples in this section use the %LET statement.
There are also several ways to assign a fileref, including the FILENAME statement, the FILENAME function in SCL, and host-specific file allocation mechanisms. However, all examples in this section use the FILENAME statement.

The IMP_TYPE Macro Variable

You must define a macro variable named IMP_TYPE to indicate which type of data you are going to import. For example, to import a TIGER/Line shapefile, submit the following statement:
%let IMP_TYPE=TIGER;
This parameter is required. The following table contains valid values for IMP_TYPE.
Valid IMP_TYPE Values and Descriptions
IMP_TYPE Value
Description
TIGER
Topologically Integrated Geographic Encoding and Referencing (TIGER) files from the U.S. Census Bureau and commercial data vendors
DYNAMAP
Dynamap files from Tele Atlas N.V.
DLG
Digital Line Graph (DLG) files from the U.S. Geological Survey and commercial data vendors
DXF
Drawing Interchange Files (DXF) produced by a variety of mapping and CAD software applications
ARC
Uncompressed ArcInfo interchange (E00) files from Esri
SASGRAPH
SAS/GRAPH map data set format
GENLINE
Generic Line format SAS data set
GENPOINT
Generic Point format SAS data set
GENPOLY
Generic Polygon format SAS data set
MAPINFO
MapInfo Interchange format files from MapInfo Corporation

The INFILE Macro Variable, TIGERPATH Macro Variable, or Required Filerefs

You must specify where the input spatial data is located. When importing TIGER/Line shapefiles dated any time after 2006 use the TIGERPATH macro variable. Otherwise, use either the INFILE macro variable or the required filerefs for your import type.
For the generic import types and the SASGRAPH import type, you accomplish this by assigning the name of a SAS data set to the INFILE macro variable. You can specify a one-level or a two-level name. One-level names are assumed to be located in the WORK library. For example:
/* The CUBA data set in the MAPS library. */
%let INFILE=MAPS.CUBA;
or
/* The NC data set in the WORK library. */
%let INFILE=NC;
For the TIGER import type, when importing TIGER/Line shapefiles dated 2007 to present, there is a particular input macro variable to use. Assign the name of the one folder where the downloaded EDGES, FACES, and FEATNAMES files were unzipped to the TIGERPATH macro variable. For example:
%let TIGERPATH = c:\Unzipped_TIGER_files;
Note that all files must be in one folder. Subfolders are ignored.
For all other import types, you must allocate filerefs to point to the files that you want to import. This includes TIGER import type for files dated 1990 – 2006. See File Reference Table for Batch Importing for additional information about the filerefs for each import type. The following table contains the import types and the filerefs that you are required to assign for them.
Import Types and Their Corresponding Filerefs
Import Type
Fileref
TIGER (1990 – 2006)
Assigns the filerefs TIGER1 and TIGER2 for file types 1 and 2, respectively. File types 4, 5, and 6 are optional; these are allocated to the filerefs TIGER4, TIGER5, and TIGER6, respectively. See Hints and Tips for Batch Importing for information about using the optional file types.
DYNAMAP
Assigns the filerefs GDT1 and GDT2 for file types 1 and 2, respectively. File types 4, 5, and 6 are optional; these are allocated to the filerefs GDT4, GDT5, and GDT6, respectively. See Hints and Tips for Batch Importing for information about using the optional file types.
DLG
Assigns the fileref DLGIN to the Digital Line Graph (DLG) file that you want to import.
DXF
Assigns the fileref DXFIN to the Drawing Interchange File (DXF) that you want to import.
ARC
Assigns the fileref ARCIN to the uncompressed file that you want to import.
MAPINFO
Assigns the filerefs MID and MIF to the MapInfo Interchange Format MID file and the MapInfo Interchange Format MIF file, respectively.

The NIDVARS and IDVARn Macro Variables

Note: NIDVARS and IDVARn macro variables are for SASGRAPH and generic import types only.
For SASGRAPH and all of the generic import types, you must provide additional information about variables in your data set.
For SASGRAPH and the generic polygon import types, you must identify the number and names of the variables that uniquely identify unit areas in the map, in hierarchical order. The NIDVARS macro variable must be set to the number of identification variables, and the IDVARn macro variables must specify, in order, the names of the identification variables. For example, for a SASGRAPH import of the MAPS.USCOUNTY data set (which contains State and County boundaries), you specify:
%let IMP_TYPE=SASGRAPH;
%let INFILE=MAPS.USCOUNTY;
%let NIDVARS=2;
%let IDVAR1=STATE;
%let IDVAR2=COUNTY;
The value of n in IDVARn ranges from 1 to the value that is specified for the NIDVARS macro variable.
For the generic line and the generic point import types, you can identify a single variable that will be used to generate layer definitions. You set NIDVARS=1 and IDVAR1=layer variable. A layer is created for each unique value of the specified layer variable. If you specify more than 16 layers, only the first 16 layers are added to the map. If you want all features to be added to a single layer, specify NIDVARS=0. For example, to add all points from a data set to a single layer, specify
%let NIDVARS=0; 
However, in another example your points can represent stores and you can have a SIZE variable that indicates whether the store is small, medium, or large. In this case you can specify the following to create three separate layers, one for each value of SIZE:
%let NIDVARS=1;
%let IDVAR1=SIZE;

The KEEPTEMP Macro Variable

During a batch import, numerous working data sets are created in the WORK library. By default, these intermediate data sets are deleted when the batch import is complete. If you encounter problems during a batch import, then you might want to retain these data sets to help identify the cause. To prevent the working data sets from being deleted, specify the following:
%let KEEPTEMP=1;

The AREA, CENTROID, and CENTROID_OPT Macro Variables

You can specify that the batch import calculate the surface area, perimeter, and centroid of the polygons when importing polygonal data. The following list contains descriptions of the AREA, CENTROID, and CENTROID_OPT macro variables:
AREA
specifies whether to calculate the enclosed areas and perimeter lengths for the area composite. Setting the value to 0 indicates that the area and perimeter are not to be calculated. Setting the value to 1 indicates that the area and perimeter are to be calculated. The calculated area is added to the polygonal index data set in a variable named AREA. A label for the AREA variable contains the storage area units. The calculated perimeter is added to the polygonal index data set in a variable named PERIMETER. A label for the PERIMETER variable contains the units.
CENTROID
specifies whether to calculate the centroid of a polygon. Setting the value to 0 indicates that centroids are not to be calculated. Setting the value to 1 indicates that centroids are to be calculated.
CENTROID_OPT
specifies the type of centroid to be calculated when the CENTROID macro variable has a value of 1. Setting the value to GEOMETRIC requests the actual calculated centroid, which might fall within the boundaries of the corresponding polygon. Setting the value to VISUAL adjusts the centroid so that it falls within the boundaries of the corresponding polygon. The centroid coordinates are added to the polygonal index data set in variables that are named CTRX and CTRY. Labels for the CTRX and CTRY variables contain the storage projection units and indicate whether it is a geometric or visual centroid.
For example, to calculate the area and visual centroids, specify the following:
%let AREA=1;
%let CENTROID=1;
%let CENTROID_OPT=VISUAL;
Note: The area, perimeter, and centroids are not calculated unless these macro variables are defined. Once defined, these variables will be used by the batch import process until reset in the current SAS session. You can reset the variables in two ways. You can set the variable to null (for example, %let AREA=;) or delete the macro variable (for example, %symdel AREA;).

Specifying the Output Parameters

The output parameters define the locations where the output data sets and catalog entries are stored and whether they will be created, replaced, or updated. These parameters are required for all import types. The following table contains the macro variables and a description of the information that each specifies.
Output Parameters Macro Variables and Descriptions
Macro Variables
Description
MAPPATH
Specifies the location where the output GIS catalog and polygonal index data sets are stored. A folder will be created if it does not exist.
This macro variable is required only when importing TIGER/Line shapefile data files dated 2007 to present.
This SAS/GIS catalog is named with the value assigned to the MAPCAT macro variable.
MAPLIB
Specifies the libref in which the output catalog is stored.
MAPCAT
Specifies the output catalog in which the entries are stored.
MAPNAME
Specifies the name for the map and coverage entries that are created.
CATHOW
Specifies the action to be used for the catalog entries. Valid values are CREATE, REPLACE, or UPDATE.
SPALIB
Specifies the libref in which the output spatial data sets are stored.
SPANAME
Specifies the name of the spatial entry and the prefix for the spatial data sets.
SPAHOW
Specifies the action to be used for the spatial data sets. Valid values are CREATE, REPLACE, or APPEND.
In addition to the variables listed in Output Parameters Macro Variables and Descriptions, other SAS macro variables enable you to override the default attribute variables imported from the FACES type shapefile.The SAS macro variables that can override defaults are listed in FACES Type Variables Imported by TIGER Release Year. Normally this is not necessary and only the parameters listed in Output Parameters Macro Variables and Descriptions are needed.
There are additional, optional output parameters that define alternate locations where the output data sets, library reference (libref), and catalog entries are stored. They also define whether the storage locations will be created, replaced, or updated. These optional parameters are used only for the TIGER import type when importing shapefiles dated 2007 to present. The values defined in the optional macro variables are blanked out at the end of the import process. The following table contains the optional macro variables and a description of the information that each specifies.
Optional Output Parameters Macro Variables and Descriptions
Macro Variables
Description
DESCRIPTION
Specifies the description to assign to the MAPNAME catalog entry.
SPATIALDATAPATH
Specifies the location where output GIS chains, nodes, and details data sets are stored. If the folder does not exist, it is created. If SPATIALDATAPATH is omitted, the GIS data sets are written to the location specified by the MAPPATH macro variable definition. If SPATIALDATAPATH is specified, then macro variable SPATIALDATALIB is required.
SPATIALDATALIB
Specifies the SAS libref name that is assigned to the location defined by the macro variable SPATIALDATAPATH. If SPATIALDATALIB is specified, then macro variable SPATIALDATAPATH is required.
SPATIALNAME
Specifies the name for the output GIS spatial catalog entry. It is also used as the base name for the chains, nodes, and details data sets by appending a ‘c’, ‘n’ and ‘d’ to the specified SPATIALNAME text string. If omitted, the definition of the macro variable MAPNAME is used.

Initiating the Batch Import

Prerequisite Step to the Batch Import

There is a step that you must take before initiating the batch import. Define all the input and output parameters that you will use in the batch import. Do this by setting the values of macro variables or by assigning filerefs.

Importing Old RT TIGER Files

The process to import the new TIGER/Line shapefiles differs from the process for importing the old RT TIGER files.
For all batch importing other than TIGER/Line shapefiles 2007 – present, the SCL importing programs are contained in the SASHELP.GISIMP.BATCH.SCL catalog entry. After defining your parameters, initiate the batch import by executing the SASHELP.GISIMP.BATCH.SCL entry with any one of the following methods:
  • Enter the following command from a SAS command line:
    AF C=SASHELP.GISIMP.BATCH.SCL
  • Submit a DM statement that will issue the AF command:
    DM 'AF C=SASHELP.GISIMP.BATCH.SCL';
  • Use the CALL DISPLAY routine in an SCL program:
    CALL DISPLAY('SASHELP.GISIMP.BATCH.SCL');
Note: You do not pass any parameters directly to the SCL entry.

Importing TIGER Shapefiles 2007 – Present

The SAS macro program that imports TIGER/Line shapefiles 2007 – present is stored in the SASHELP.GISIMP.TIGER2GIS.SOURCE catalog entry.
After defining your parameters, initiate the batch import by executing SASHELP.GISIMP.TIGER2GIS.SOURCE as follows:
  • Compile the SAS macro programs:
    FILENAME TIGER CATALOG 'SASHELP.GISIMP.TIGER3GIS.SOURCE'; 
     %INCLUDE TIGER /SOURCE2;
  • Invoke the SAS macro program to import the shapefiles:
    %TIGER2GIS