BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
kleinl1
Fluorite | Level 6

I am using PROC SGMAP to spatially plot locations of air-bnbs in San Francisco. I am trying to color code the points based on reviews (i.e. red=poor, yellow=standard, and green=excellent). Using this code:

proc sgmap plotdata=checkout.airbnb_SF;
ESRIMAP URL = 'https://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer';
scatter X = longitude Y = latitude / group=score_class markerattrs=(symbol=circlefilled size=5) transparency=0.6;
run;

I am able to produce a plot with the default colors:

kleinl1_0-1587602434232.png

I have tried using style modification:

proc template;
 define style MyStyle;
 parent = Styles.Listing;
/* Attempt to change to different colors */
 class GraphData1 / contrastcolor = GraphColors('gcdata4');
 class GraphData2 / contrastcolor = GraphColors('gcdata5');
 class GraphData3 / contrastcolor = GraphColors('gcdata6');
 end;
run;
ods listing style=MyStyle;
proc sgmap plotdata=checkout.airbnb_SF;
ESRIMAP URL = 'https://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer';
scatter X = longitude Y = latitude / group=score_class markerattrs=(symbol=circlefilled size=5) transparency=0.6;
run;

and %Modstyle:

%modstyle
 (name=MyStyle 
 ,parent=Listing 
 ,type=CLM 
 ,colors=cx543005 cx9D3CDB cx7F8E1F 
 );
ods listing style=MyStyle;
proc sgmap plotdata=checkout.airbnb_SF;
ESRIMAP URL = 'https://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer';
scatter X = longitude Y = latitude / group=score_class markerattrs=(symbol=circlefilled size=5) transparency=0.6;
run;

However, the default colors do not change. Using STYLEATTRS yields an error that the "Statement is not valid or it is used out of proper order":

proc sgmap plotdata=checkout.airbnb_SF_Train;
STYLEATTRS DATACOLORS=(green, yellow, red);
ESRIMAP URL = 'https://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer';
scatter X = longitude Y = latitude / group=score_class markerattrs=(symbol=circlefilled size=5) transparency=0.6;
run;

I also tried using an attribute map, but proc sgmap did not like the inclusion of dattrmap=<my attribute map>. I'm at a loss of what else to try to change the color defaults. 

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
DanH_sas
SAS Super FREQ

For now, you will have to use the custom style approach. Your style definition works for me. Do you happen to also have ODS HTML open, and you are looking at the HTML output instead of the LISTING output?

 

BTW, both the STYLEATTRS statement and attribute map support will be in the next release for SGMAP.

View solution in original post

5 REPLIES 5
DanH_sas
SAS Super FREQ

What version of SAS 9.4 are you using -- 9.4m5 or 9.4m6?

 

You can use:

%put &sysvlong;

to show the version. Just post the output from the log here. Thanks!

kleinl1
Fluorite | Level 6
It's 9.4m6 (9.04.01M6P111518). Thanks!
Jay54
Meteorite | Level 14

I am not as familiar with SGMAP features.  However, one workaround to try is to restructure your Airbnb data in "Wide" format, like Excel.  One column per type (Poor, Standard, Excellent).  Use missing values where needed.  Then, you can use three separate scatter statements, one per column, and set the colors explicitly.  

DanH_sas
SAS Super FREQ

For now, you will have to use the custom style approach. Your style definition works for me. Do you happen to also have ODS HTML open, and you are looking at the HTML output instead of the LISTING output?

 

BTW, both the STYLEATTRS statement and attribute map support will be in the next release for SGMAP.

kleinl1
Fluorite | Level 6

I wasn't looking at the HTML output -- thank you for pointing that out!!

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 5 replies
  • 1268 views
  • 0 likes
  • 3 in conversation