BookmarkSubscribeRSS Feed
sschiro
Fluorite | Level 6

I'm trying to control the colors on a map - plotted using proc sgmap.  I keep getting an error when I try to use dattrmap to assign the colors, likely because I'm using SAS v9.4.    Any suggestions on how to control the colors used in the map?  

 

data attrmap;
input id $1 value $3-19 fillcolor $20-40;
datalines;
A Greater than 60 cx3182bd
A 31 - 60 cx6baed6
A 11 - 30 cx9ecae1
A 1 - 10 cxc6dbef
A 0 cxFFFFFF; 
run;

ods graphics / border outputfmt=png;
title 'NC Counties with Cardiac Surgeries in 2022';
proc sgmap mapdata=nc maprespdata=county_pop plotdata=hospitals;* dattrmap=attrmap;
choromap group / mapid=county lineattrs=(color=blue) id=county name='counties' attrmap=A;
bubble x=long y=lat size=count / fillattrs=(color=yellow)
name='hospitals';* datalabel=county
datalabelattrs=(color=black
size=9
style=italic);
keylegend 'counties' / title='County Surgery Count';
keylegend 'hospitals' / title='Hospital';
run;

ods graphics / reset;
title;

 

Error messages:

5816 proc sgmap mapdata=nc maprespdata=county_pop plotdata=hospitals dattrmap=attrmap;*
--------
22
76
5816! dattrvar=A;
ERROR 22-322: Syntax error, expecting one of the following: ;, (, DESCRIPTION, MAPDATA,
MAPRESPDATA, NOAUTOLEGEND, PLOTDATA.
ERROR 76-322: Syntax error, statement will be ignored.
5817 choromap group / mapid=county lineattrs=(color=blue) id=county name='counties' attrmap=A;
-------
22
76
ERROR 22-322: Syntax error, expecting one of the following: ;, DENSITY, DISCRETE, ID,
LEGENDLABEL, LINEATTRS, MAPID, NAME, TRANSPARENCY.
ERROR 76-322: Syntax error, statement will be ignored.

1 REPLY 1
jeanleid
Fluorite | Level 6

Hi,

First, when I ran a proc print of you dataset 'attrmap' the variable 'fillcolor' is only populated for the first row.  Double check that this dataset looks the way you want it to.

Next, double check the syntax you are using on both the proc sgmap and choromap statements.  It should look like:

 

proc sgmap mapdata= nc

                        plotdata= hospitals

                        maprespdata= county_pop dattrmap= attrmap ;

  choromap  group / mapid=county lineattrs=(color=blue) id=county name='counties'  attrid= A;

 run;

 

Maps are tricky so sometimes it helps to run each layer (choro, bubble) separately.  Once you are satisfied that each layer works, then run the entire code.

 

Hope this helps!

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 273 views
  • 0 likes
  • 2 in conversation