Dear Community,
I am working on a bar graph that uses default colors (color of the bars) and I need to know the code (names) for those colors.
Is there any way to find out what the code (names) for(of) those exact colors are?
Thank you for any suggestions!
Best regards,
Karoline
Use proc template to list the definition of the ODS Style you are using.
Example:
proc template; source styles.htmlblue; run;
You may need to search for the color definitions depending on exactly which style you place on the Source statement. The colors might be defined in the parent and may need to look at the parent to map other values used for colors.
The output from the above my system is:
610 proc template; 611 source styles.htmlblue; define style Styles.Htmlblue; parent = styles.statistical; class GraphColors / 'gndata12' = cxECE8C4 'gndata11' = cxDBD8F8 'gndata10' = cxC6E4BF 'gndata9' = cxE6CEAD 'gndata8' = cxE5C1D4 'gndata7' = cxCCDFF0 'gndata6' = cxDDDEB5 'gndata5' = cxDBC7E7 'gndata4' = cxD5C6B4 'gndata3' = cxB7D4D3 'gndata2' = cxE7B3B4 'gndata1' = cxBBC2DC 'gndata' = cxBBC2DC 'gofill' = cxFAFBFE 'gblockheader' = cxcfd5de 'gcphasebox' = cx989EA1 'gphasebox' = cxDBE6F2 'gczonec' = cxBECEE0 'gzonec' = cxCCDCEE 'gczoneb' = cxCCDCEE 'gzoneb' = cxD7E5F3 'gzonea' = cxE3EDF7 'gconramp3cend' = cx9C1C00 'gconramp3cneutral' = cx222222 'gconramp3cstart' = cx0E36AC 'gramp3cend' = cxD05B5B 'gramp3cneutral' = cxFAFBFE 'gramp3cstart' = cx667FA2 'gcontrollim' = cxE6F2FF 'gccontrollim' = cxBFC7D9 'gruntest' = cxCAE3FF 'gcruntest' = cxBF4D4D 'gclipping' = cxFFFFC6 'gcclipping' = cxC1C100 'gaxis' = cx989EA1 'greferencelines' = cx989EA1; class colors / 'link2' = cx0000FF 'link1' = cx800080 'docbg' = cxFAFBFE 'contentbg' = cxFAFBFE 'systitlebg' = cxFAFBFE 'titlebg' = cxFAFBFE 'proctitlebg' = cxFAFBFE 'headerbg' = cxEDF2F9 'captionbg' = cxFAFBFE 'captionfg' = cx112277 'bylinebg' = cxFAFBFE 'notebg' = cxFAFBFE 'tablebg' = cxFAFBFE 'batchbg' = cxFAFBFE 'systitlefg' = cx112277 'titlefg' = cx112277 'proctitlefg' = cx112277 'bylinefg' = cx112277 'notefg' = cx112277; class Header / bordercolor = cxB0B7BB backgroundcolor = cxEDF2F9 color = cx112277; class Footer / bordercolor = cxB0B7BB backgroundcolor = cxEDF2F9 color = cx112277; class RowHeader / bordercolor = cxB0B7BB backgroundcolor = cxEDF2F9 color = cx112277; class RowFooter / bordercolor = cxB0B7BB backgroundcolor = cxEDF2F9 color = cx112277; class Table / cellpadding = 5; class Graph / attrpriority = "Color"; class GraphFit2 / linestyle = 1; class GraphClipping / markersymbol = "circlefilled"; end; NOTE: Path 'Styles.Htmlblue' is in: SASHELP.TMPLMST. 612 run;
The Gndataxx replace the default values assigned in the parent style of Styles.Statistical.
You will need to reference the SAS documentation for colors for the different ways of defining colors. Look in the documentation for "Color Naming Schemes". Here the values are RGB (the CX tells SAS that is the naming type) and the pairs of characters hold hex values of the 256 values possible for each of the reg, green and blue components of the displayed color.
The reference names for the color elements depends on which element. The GraphdataN are the basic names with up to 12 generally.
Use proc template to list the definition of the ODS Style you are using.
Example:
proc template; source styles.htmlblue; run;
You may need to search for the color definitions depending on exactly which style you place on the Source statement. The colors might be defined in the parent and may need to look at the parent to map other values used for colors.
The output from the above my system is:
610 proc template; 611 source styles.htmlblue; define style Styles.Htmlblue; parent = styles.statistical; class GraphColors / 'gndata12' = cxECE8C4 'gndata11' = cxDBD8F8 'gndata10' = cxC6E4BF 'gndata9' = cxE6CEAD 'gndata8' = cxE5C1D4 'gndata7' = cxCCDFF0 'gndata6' = cxDDDEB5 'gndata5' = cxDBC7E7 'gndata4' = cxD5C6B4 'gndata3' = cxB7D4D3 'gndata2' = cxE7B3B4 'gndata1' = cxBBC2DC 'gndata' = cxBBC2DC 'gofill' = cxFAFBFE 'gblockheader' = cxcfd5de 'gcphasebox' = cx989EA1 'gphasebox' = cxDBE6F2 'gczonec' = cxBECEE0 'gzonec' = cxCCDCEE 'gczoneb' = cxCCDCEE 'gzoneb' = cxD7E5F3 'gzonea' = cxE3EDF7 'gconramp3cend' = cx9C1C00 'gconramp3cneutral' = cx222222 'gconramp3cstart' = cx0E36AC 'gramp3cend' = cxD05B5B 'gramp3cneutral' = cxFAFBFE 'gramp3cstart' = cx667FA2 'gcontrollim' = cxE6F2FF 'gccontrollim' = cxBFC7D9 'gruntest' = cxCAE3FF 'gcruntest' = cxBF4D4D 'gclipping' = cxFFFFC6 'gcclipping' = cxC1C100 'gaxis' = cx989EA1 'greferencelines' = cx989EA1; class colors / 'link2' = cx0000FF 'link1' = cx800080 'docbg' = cxFAFBFE 'contentbg' = cxFAFBFE 'systitlebg' = cxFAFBFE 'titlebg' = cxFAFBFE 'proctitlebg' = cxFAFBFE 'headerbg' = cxEDF2F9 'captionbg' = cxFAFBFE 'captionfg' = cx112277 'bylinebg' = cxFAFBFE 'notebg' = cxFAFBFE 'tablebg' = cxFAFBFE 'batchbg' = cxFAFBFE 'systitlefg' = cx112277 'titlefg' = cx112277 'proctitlefg' = cx112277 'bylinefg' = cx112277 'notefg' = cx112277; class Header / bordercolor = cxB0B7BB backgroundcolor = cxEDF2F9 color = cx112277; class Footer / bordercolor = cxB0B7BB backgroundcolor = cxEDF2F9 color = cx112277; class RowHeader / bordercolor = cxB0B7BB backgroundcolor = cxEDF2F9 color = cx112277; class RowFooter / bordercolor = cxB0B7BB backgroundcolor = cxEDF2F9 color = cx112277; class Table / cellpadding = 5; class Graph / attrpriority = "Color"; class GraphFit2 / linestyle = 1; class GraphClipping / markersymbol = "circlefilled"; end; NOTE: Path 'Styles.Htmlblue' is in: SASHELP.TMPLMST. 612 run;
The Gndataxx replace the default values assigned in the parent style of Styles.Statistical.
You will need to reference the SAS documentation for colors for the different ways of defining colors. Look in the documentation for "Color Naming Schemes". Here the values are RGB (the CX tells SAS that is the naming type) and the pairs of characters hold hex values of the 256 values possible for each of the reg, green and blue components of the displayed color.
The reference names for the color elements depends on which element. The GraphdataN are the basic names with up to 12 generally.
Thank you very much! This solved my problem 🙂
See the article, "What colors does PROC SGPLOT use for markers?" Although the article talks about marker colors in a scatter plot, you can use similar ideas to find the fill colors in a bar chart.
Regarding the color "code" versus "name," the colors probably are only defined in terms of the RGB values (like CX556B2F). However, if you need a color NAME (like "Dark Olive Green"), there is a way to find the closest "color name" to a given RGB color. See "How to assign a name to a color."
Thank you, this is very useful to know!
Hello @KarolineN,
As ballardw and Rick_SAS have explained, you can investigate ODS templates to find out the default color definitions. However, this assumes that you are using ODS graphics (and not traditional SAS/GRAPH output) and that you know the name of the current ODS style. Moreover, you have to match the colored graph elements in front of you to the correct items in a long list of abstract names such as "gndata1" that you read in the ODS template, which I find difficult.
Here is an alternative, very general approach that I have used in similar situations (using SAS under Windows):
Thank you! This is also very useful to know and might come in handy later:)
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.