How can I assign a custom color set to gchart lines? I’m using indexes with proc template. (Using Enterprise Gude.)
data test2; set sashelp.workers; if electric > 270 then grouping =1; else if electric > 255 then grouping =2; else grouping =3; run; proc template; define statgraph layoutoverlay; /* Define the attributes for the data groups */ begingraph / datacolors=(pink brown orange) datacontrastcolors=(pink brown orange) datalinepatterns=(1 1 1) datasymbols=(CircleFilled TriangleFilled SquareFilled); entrytitle "Trends in Employment Levels"; entrytitle "Electrical"; layout overlay / cycleattrs=true xaxisopts=(display=(ticks tickvalues)) yaxisopts=(label="Number of Workers (thousands)"); seriesplot x=date y=electric / group=grouping; endlayout; endgraph; end; run; proc sgrender data=test2 template=layoutoverlay; run;
Are you talking about gchart outlines? Can you send a code snippit?
I need to reword my question doing some research.
I wouldn't normally associate GCHART with lines, usually that would be GPLOT. In which case SYMBOL1 through SYMBOL255 are available to assign line characteristics such as color, line type (various dash dot combinations) and thickness.
data test2; set sashelp.workers;
if electric > 270 then grouping =1;
else if electric > 255 then grouping =2;
else grouping =3;
run;
proc print data=sashelp.workers;
run;
proc template;
define statgraph layoutoverlay;
begingraph;
entrytitle "Trends in Employment Levels";
layout overlay / cycleattrs=true
xaxisopts=(display=(ticks tickvalues))
yaxisopts=(label="Number of Workers (thousands)");
seriesplot x=date y=electric / group=grouping
curvelabel="Electrical"
curvelabellocation=outside;
endlayout;
endgraph;
end;
run;
proc sgrender data=test2 template=layoutoverlay;
run;
In this example I want to define the first line as purple then yellow then orange.
I'm trying to merge two template ideas together. One for colors and one for the graph. Not sure on the syntax.
data test2; set sashelp.workers;
if electric > 270 then grouping =1;
else if electric > 255 then grouping =2;
else grouping =3;
run;
/*proc print data=sashelp.workers;
run;*/
proc template;
define statgraph layoutoverlay;
parent=styles.listing;
style GraphData1 /
ContrastColor=pink
Color=pink
MarkerSymbol="CircleFilled"
Linestyle=1;
style GraphData2 /
ContrastColor=brown
Color=brown
MarkerSymbol="TriangleFilled"
Linestyle=1;
style GraphData3 /
ContrastColor=orange
Color=orange
MarkerSymbol="SquareFilled"
Linestyle=1;
begingraph;
entrytitle "Trends in Employment Levels";
layout overlay / cycleattrs=true
xaxisopts=(display=(ticks tickvalues))
yaxisopts=(label="Number of Workers (thousands)");
seriesplot x=date y=electric / group=grouping
curvelabel="Electrical"
curvelabellocation=outside;
endlayout;
endgraph;
end;
run;
proc sgrender data=test2 template=layoutoverlay;
run;
data test2; set sashelp.workers; if electric > 270 then grouping =1; else if electric > 255 then grouping =2; else grouping =3; run; proc template; define statgraph layoutoverlay; /* Define the attributes for the data groups */ begingraph / datacolors=(pink brown orange) datacontrastcolors=(pink brown orange) datalinepatterns=(1 1 1) datasymbols=(CircleFilled TriangleFilled SquareFilled); entrytitle "Trends in Employment Levels"; entrytitle "Electrical"; layout overlay / cycleattrs=true xaxisopts=(display=(ticks tickvalues)) yaxisopts=(label="Number of Workers (thousands)"); seriesplot x=date y=electric / group=grouping; endlayout; endgraph; end; run; proc sgrender data=test2 template=layoutoverlay; run;
Turns out I actually need to do the same thing with gchart bars. This is done with Patern statements.
According to:
I need group = panelBy3 for colors to show up here? Can I have the same first color without the group?
data test2; set sashelp.workers; if electric > 270 then grouping =1; else if electric > 255 then grouping =2; else grouping =3; if electric > 270 then panelBy1 =1; else if electric > 255 then panelBy1 =2; else panelBy1 =3; if electric > 270 then panelBy2 =1; else if electric > 255 then panelBy2 =2; else panelBy2 =3; if electric > 270 then panelBy3 =1; else if electric > 255 then panelBy3 =2; else panelBy3 =3; run; proc sgpanel data=test2 ; panelby panelBy1 panelBy2 / layout=lattice uniscale=column novarname columns=4 onepanel headerbackcolor="969491" HEADERATTRS=(Weight=Bold color=white); styleattrs datacontrastcolors=(CXFFBA00 black CX969491 CX6341 CX63513D CX768692 CX69B3E7 CX6BCABA CXC6AA76 CXE9DF97 CXC4D600 CXE57200) datacolors=(CXFFBA00 black CX969491 CX6341 CX63513D CX768692 CX69B3E7 CX6BCABA CXC6AA76 CXE9DF97 CXC4D600 CXE57200); vbar grouping / response=electric nostatlabel grouporder=ascending group = panelBy3;
for a single color use: vbar grouping / response=electric nostatlabel fillattrs=(color=CXFFBA00);
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.