BookmarkSubscribeRSS Feed
0 Likes

RGB color codes are specified in SAS as CXrrggbb, e.g., CXFF0000 for red. In several other languages (including R, Python, and HTML/CSS), the equivalent syntax is #rrggbb. I suggest that SAS allows for both #rrggbb and CXrrggbb as equivalent, alternative syntaxes. This will make it easier to copy & paste colors between languages.

2 Comments
Ksharp
Super User

SAS do allow #rrggbb to be right color.

Did you try an example for it ?

 

proc sgplot data=sashelp.class;
scatter x=weight y=height/markerattrs=(color='#FF0000'  symbol=circlefilled);
run;

Ksharp_0-1757145466070.png

 

dmuenz
Fluorite | Level 6

Thank you, Ksharp! It had not occurred to me to try putting quotes around the #rrggbb color, since quotes aren't needed with the CX syntax.

 

Actually, I just tested PROC REPORT's support for the # syntax, and here it only works without quotes. E.g., this works:

 

proc report data=sashelp.class style(header)=[background=#FF0000];
run;

 

So, I guess my suggestion then becomes:

  1. Allow #rrggbb to be used without quotes in the SG procedures. I think that will make this syntax more discoverable (at least by me 😀).
  2. Update the documentation to mention the #rrggbb syntax. In particular the "Color-Naming Schemes" page associated with the SG procs does not appear to mention this.