Contents: Purpose / Requirements / Usage / Limitations / Example / References
Creates custom region maps quickly using PROC GMAP and without having to know the intricacies of the procedure.
Base SAS Software and SAS/GRAPH. You will first need to download the desired region shp file (For example, State, County or Zip shp file. You can download shape files here: https://www.census.gov/geo/maps-data/data/tiger-cart-boundary.html).
Download the file regmap.sas attached with this post and save it in your work directory (or any desired location). Replace the text within quotes in the following statement with the location of the %REGMAP macro definition file on your system. In your SAS program or in the SAS editor window, specify this statement to define the %REGMAP macro and make it available for use:
%inc "<location of your file containing the REGMAP macro>";
Following this statement, you may call the %REGMAP macro.
The required arguments for the %REGMAP macro are as follows:
SAS data set to be analyzed.
Region map shape file to output the data upon (For example, State, County or Zip shp file).
Name of the geo variable that exists in both your data and the shape file. This will be the unique identifier of a region/location.
Name of the variable that is to be outputted on the region map.
Title for the region map.
Starting color in the color scale.
Ending color in the color scale.
Labels for the regions.
Labels cannot be outputted on the map as of now but it’s a work in progress.
/*First step is to import the shape file*/ Proc MAPIMPORT OUT=State Datafile='your-location\cb_2016_us_state_20m.shp'; run; /*Make sure that the common_id variable is in the same format for both your dataset and shape file. Note that when you import a shape file, SAS creates a dataset. You may manipulate this dataset just like in the following code.*/ data State2; set State; STATE=input(STATEFP,BEST12.); run; /*Now you set reference to where the REGMAP macro is located*/ %inc "your-location/regmap.sas"; /*Lastly, just call the macro funtion that creates the map*/ %regmap(your_data=Pop,shp_file=State2,common_id=STATE, response_var=CENSUS2010POP, title="US Population",start_color=CXFF0000 ,end_color=CX00FF00);
SAS Support Samples & Notes: https://support.sas.com/sassamples/graphgallery/PROC_GMAP.html
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.