As the first step in the decommissioning of sasCommunity.org the site has been converted to read-only mode.
Here are some tips for How to share your SAS knowledge with your professional network.
- This is a work in progress. Feel free to contribute to this article.
The MAPIMPORT procedure is used to import shape files into SAS as a SAS mapping dataset.
- PROC MAPIMPORT <options> ;
- zero or more statements ;
The options can be one or more of:
- Where shapefile is a character variable, or string constant enclosed in quotes, that specifies the name and path of the shapefile (*.shp) to import. Although only the shape file is specified, associated files must all have the same path.
- Where dataset is a character variable, or string constant enclosed in quotes, that specifies the name of the output SAS map-file dataset. If omitted the ouput data set is given a unique name.
- Including this option causes a list of the names, type, width and decimal places and number of identifier fields found in the shapefile to be listed in the SAS log. These identifier fields can be selectively included with an ID statement.
- Including this option will create a variable called _ID_ in the output dataset. The value of the _ID_ variable is a unique number for each map shape. This can be useful if only the shapefile is available or none of the other map identifier fields are suitable.
- EXCLUDE shapefile field list ;
This statement identifies the names of the shapefile fields to excluded from the output data set. The list can be enclosed in single or double quotes if the name(s) are not valid SAS identifiers.
Any field not listed in this statement will appear in the output dataset, unless a RENAME or SELECT statement is also used. Because the shapefile field names specified in this statement are not included in the output dataset they should not be used in an ID, RENAME or SELECT statement.
- ID shapefile field list ;
This statement identifies the name(s) of the shapefile field(s) that are used to identify each of the map polygons in the output data set. The list can be enclosed in single or double quotes if the name(s) are not valid SAS identifiers.
Usually it is only necessary to have one ID field, since one of the fields should identify each map shape uniquely. However, some maps have multiple layers and it is sometimes necessary to extract each layer from the map separately. By specifying which field to use as a unique identifier, the MAPIMPORT procedure can re-order the map polygons for the particular ID field specified. If there are multiple map polygons with the same value of the ID variable, then each polygon is given a unique SEGMENT number. SEGMENT numbers are integer values that start at 1.
If an ID statement is not used then the order of the map polygons found in the shapefile is used. This might cause a map to display incorrectly in the GMAP procedure if the correct ID field is not used in that procedure. The CREATE_ID_ procedure option is useful where the specific ID field is not known or does not exist.
- RENAME rename pair list ;
- where the rename pair list is a list of one or more expressions like shapefile field = variable name that indicate the output dataset variable name of the corresponding a shapefile field. The shapefile field can be enclosed in single or double quotes if the field name is not valid SAS identifiers. The variable name must be a valid SAS identifier and cannot be enclosed in quotes.
- SELECT shapefile field name list ;
This statement identifies the shapefile field names to be included in the data set. The list can be enclosed in single or double quotes if the name(s) are not valid SAS identifiers.
Any field name not listed will be excluded from the output dataset.
If the SELECT statement is omitted and there is no EXCLUDE statement then all field names are included in the output dataset.
Field names that appear in the EXCLUDE statement should not appear in the SELECT statement. Generally it is only necessary to use one or other of these statements, not both.
The output dataset will contain the following variables (columns):
- _ID_ - if the CREATE_ID_ procedure option was used.
as well as any field names that were specified in any SELECT statement, or all field names not specified in the EXCLUDE statement.