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: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1398 views
  • 0 likes
  • 3 in conversation