Hi SAS experts,
Am tryng to create a proc template to add colors, and refering this template in proc sgrender procedurs.
But the colors which i have defined in the template are not working in sgrender. Please help. below is my code;
Is there is any other way to add colors.
data new;
input year name$ points;
datalines;
2006 a 900
2007 a 267
2008 a 290
2009 a 677
2006 b 1000
2007 b 2000
2008 b 2678
2009 b 677
2006 c 500
2007 c 400
2008 c 678
2009 c 877
2006 d 500
2007 d 600
2008 d 364
2009 d 466
2006 e 555
2007 e 654
2008 e 365
2009 e 645
2006 f
2007 f
2008 f
2009 f
run;
proc template;
define statgraph abc;
begingraph / datacolors=(CXE5CCFF CXFFCC99 CX64BEEB CXC4DA5A CX404040 );
layout overlay/
xaxisopts=(linearopts=(tickvalueformat=4.0 tickvaluesequence=(start=2006 end=2009 increment=1)))
yaxisopts=(griddisplay=on gridattrs=(pattern=dot)
linearopts=(tickvalueformat=(extractscale=true)));
seriesplot x=year
y=points / name= "ST3" group=name LINEATTRS = (THICKNESS = 3) display=all ;
discretelegend "ST3" / title="name" exclude=("f") ;
endlayout;
endgraph;
end;
proc sgrender data=new template=abc;
run;
You need to use the DATACONTRASTCOLORS option instead of the DATACOLORS option. The DATACOLORS option is for FILL colors, but you are using a SERIESPLOT. Line and markers get their colors from DATACONTRASTCOLORS.
Hope this helps!
Dan
What do you mean "are not working"? I ran that code you have posted and I see a graph with colors.
What I meant is the colors which i have declared in the template are not reffering in the graph, it is taking the by default colors.
Hmm, never used datacolors in my graphs. From the docs it seems that only applies to fill colors - which would indicate to me bar charts and that type of thing rather than line color. Generally speaking I setup my line information in a style template, then use that in geration of the output file - see below. There are other methods to get color and such like, by adding lineattrs and linegroupattrs and such like. Here is a site I sue a lot for graphs, have filtered for series plot:
http://blogs.sas.com/content/graphicallyspeaking/?s=seriesplot
(worth looking at the whole site though).
data new; input year name$ points; datalines; 2006 a 900 2007 a 267 2008 a 290 2009 a 677 2006 b 1000 2007 b 2000 2008 b 2678 2009 b 677 2006 c 500 2007 c 400 2008 c 678 2009 c 877 2006 d 500 2007 d 600 2008 d 364 2009 d 466 2006 e 555 2007 e 654 2008 e 365 2009 e 645 2006 f 2007 f 2008 f 2009 f run; proc template; define style Styles.mystyle; parent=styles.listing; style GraphData1 from GraphData1 / ContrastColor=red Color=red MarkerSymbol="CircleFilled" Linestyle=1; style GraphData2 from GraphData2 / ContrastColor=black Color=black MarkerSymbol="TriangleFilled" Linestyle=1; style GraphData3 from GraphData3 / ContrastColor=orange Color=orange MarkerSymbol="SquareFilled" Linestyle=1; style GraphData4 from GraphData5 / ContrastColor=green Color=green MarkerSymbol="SquareFilled" Linestyle=1; style GraphData5 from GraphData5 / ContrastColor=purple Color=purple MarkerSymbol="SquareFilled" Linestyle=1; end; run; proc template; define statgraph abc; begingraph; layout overlay/ xaxisopts=(linearopts=(tickvalueformat=4.0 tickvaluesequence=(start=2006 end=2009 increment=1))) yaxisopts=(griddisplay=on gridattrs=(pattern=dot) linearopts=(tickvalueformat=(extractscale=true))); seriesplot x=year y=points / name= "ST3" group=name LINEATTRS = (THICKNESS = 3) display=all ; discretelegend "ST3" / title="name" exclude=("f") ; endlayout; endgraph; end; ods rtf file="s:\t.rtf" style=mystyle; proc sgrender data=new template=abc; run; ods rtf close;
Thank you RW9 there is lot of information that helps me.
You need to use the DATACONTRASTCOLORS option instead of the DATACOLORS option. The DATACOLORS option is for FILL colors, but you are using a SERIESPLOT. Line and markers get their colors from DATACONTRASTCOLORS.
Hope this helps!
Dan
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.