Batch Importing |
Example 1: Batch Importing TIGER Files |
This example imports the data for Wake County, North Carolina, from a 2006 Second Edition TIGER file, and appends the data for neighboring Durham County, North Carolina, from a separate TIGER file.
/* Define the input parameters for Wake County, North Carolina. */ /* Define the import type. */ %let IMP_TYPE = TIGER; /* Specify the complete path to the TIGER files for Wake County which were downloaded and unzipped using the required TIGER1 and TIGER2 filerefs. */ filename TIGER1 'tgr37183.rt1'; filename TIGER2 'tgr37183.rt2'; /* Define the output parameters for Wake County, North Carolina. */ %let MAPLIB = SASUSER; %let MAPCAT = TIGER; %let MAPNAME = COUNTIES; %let CATHOW = CREATE; %let SPALIB = SASUSER; %let SPANAME = COUNTIES; %let SPAHOW = CREATE; /* Initiate the batch import by executing the SCL entry. */ DM 'AF C=SASHELP.GISIMP.BATCH.SCL'; /* Define the input parameters for Durham County, North Carolina. */ /* IMP_TYPE value stays the same, so you just need to reallocate the filerefs to point to the spatial data that was downloaded and unzipped for Durham County. */ filename TIGER1 'tgr37063.rt1'; filename TIGER2 'tgr37063.rt2'; /* Define the output parameters for Durham County, North Carolina. */ /* The locations will stay the same, so you only need to redefine CATHOW and SPAHOW to update the catalog entries and append the spatial data sets for the second import. */ %let CATHOW = UPDATE; %let SPAHOW = APPEND; /* Initiate the batch import by executing the SCL entry a second time; this time to add the Durham County data to the Wake County data. */ DM 'AF C=SASHELP.GISIMP.BATCH.SCL';
When the import completes, you can open the map named SASUSER.TIGER.COUNTIES. This map displays Wake and Durham counties.
Example 2: Batch Importing SASGRAPH and GENPOINT Data |
This example creates a map of North Carolina with the state and county boundaries and then adds points at city locations. The state and county boundaries are imported from the MAPS library by using the SASGRAPH import type, and the points are appended using the GENPOINT import type.
/* Construct the data sets to be imported into SAS/GIS. The North Carolina state and county boundaries are obtained from the MAPS.USCOUNTY data set and the North Carolina city locations are obtained from the MAPS.USCITY data set. Both data sets are supplied with SAS/GRAPH software. */ /* Subset just the boundaries for the state of North Carolina. */ data sasuser.nc; set maps.uscounty; /* 37 is the FIPS code for North Carolina.*/ where state=37; run; /* Subset just the cities in North Carolina. */ data sasuser.nccities; set maps.uscity; /* 37 is the FIPS code for North Carolina. */ where state=37; run; /* Define the input parameters for the SASGRAPH import of the boundaries. */ /* Define the import type. */ %let IMP_TYPE = SASGRAPH; /* Specify where map data set is located. */ %let INFILE=SASUSER.NC; /* Specify the identification variables, in hierarchical order (largest polygon first). */ %let NIDVARS=2; %let IDVAR1=STATE; %let IDVAR2=COUNTY; /* Define the output parameters for the boundaries. */ %let MAPLIB = SASUSER; %let MAPCAT = NC; %let MAPNAME = NC; %let CATHOW = CREATE; %let SPALIB = SASUSER; %let SPANAME = NC; %let SPAHOW = CREATE; /* Initiate the batch import by executing the SCL entry. */ DM 'AF C=SASHELP.GISIMP.BATCH.SCL'; /* Define the input parameters for the batch import of the GENPOINT data set for the cities. */ /* The import type has changed, so redefine the IMP_TYPE macro variable. */ %let IMP_TYPE=GENPOINT; /* Specify where the generic point data is located. */ %let INFILE=SASUSER.NCCITIES; /* Define the number of identification variables. If you want all of the cities to be contained in one layer, don't define any. */ %let NIDVARS=0; /* Define the output parameters for the cities. */ /* The locations will stay the same, so you only need to redefine CATHOW and SPAHOW to update the catalog entries and append the spatial data sets for the second import. */ %let CATHOW = UPDATE; %let SPAHOW = APPEND; /* Initiate the batch import by executing the SCL entry a second time; this time to add the points to the boundaries. */ DM 'AF C=SASHELP.GISIMP.BATCH.SCL';
When the import completes, you can open the map named SASUSER.NC.NC. This map displays the state and county boundaries for North Carolina. You can choose to display the city points on the map.
Copyright © 2009 by SAS Institute Inc., Cary, NC, USA. All rights reserved.