BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
DavidPhillips2
Rhodochrosite | Level 12

How can I assign a custom color set to gchart lines?  I’m using indexes with proc template.  (Using Enterprise Gude.)

1 ACCEPTED SOLUTION

Accepted Solutions
DavidPhillips2
Rhodochrosite | Level 12
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;   

View solution in original post

8 REPLIES 8
DanH_sas
SAS Super FREQ

Are you talking about gchart outlines? Can you send a code snippit?

DavidPhillips2
Rhodochrosite | Level 12

I need to reword my question doing some research.

ballardw
Super User

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.

DavidPhillips2
Rhodochrosite | Level 12

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.

DavidPhillips2
Rhodochrosite | Level 12

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;

DavidPhillips2
Rhodochrosite | Level 12
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;   
DavidPhillips2
Rhodochrosite | Level 12

Turns out I actually need to do the same thing with gchart bars.  This is done with Patern statements.

DavidPhillips2
Rhodochrosite | Level 12

According to:

http://support.sas.com/documentation/cdl/en/grstatproc/67909/HTML/default/viewer.htm#p1dt33l6a6epk6n...

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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 8 replies
  • 1625 views
  • 2 likes
  • 3 in conversation