## SGPanel : one color per graphic

Solved
Occasional Contributor
Posts: 9

# SGPanel : one color per graphic

Good afternoon !

I need your help : I use a SGPanel and I would like to choose le bars colors : for exemple all bars blue for the first graph, orange for the second .. Is it possible?

proc sgpanel data=table_end ;

panelby variable / novarname BORDER ROWS=2 columns=3;

hbar &var_4c / response = frequence1 BARWIDTH=.6;

ROWaxis type = discrete  discreteorder = data display=(nolabel NOTICKS NOLINE )VALUESHINT  ;

colaxis min=0 max=100  label = "Percent (%)" ;

refline 0 20 40 60 80 100/axis=x LINEATTRS=(THICKNESS=.5)  ;

run;

quit;

Accepted Solutions
Solution
‎05-02-2013 10:25 AM
Posts: 5,539

## Re: SGPanel : one color per graphic

With SAS 9.3, use an attribute map and specufy the same variable for panel and groups, as in the following example :

data test;
do mean= 5, 10;
do i = 1 to 100;
x = rand("Poisson", mean);
output;
end;
end;
run;

data myattrmap;
input ID \$ value \$ linecolor \$ fillcolor \$;
datalines;
myid  5  blue blue

myid  10 orange orange

;

proc sgpanel data=test dattrmap=myattrmap;
panelby mean;
hbar x / group=mean attrid=myid;
run;

PG

PG

All Replies
Solution
‎05-02-2013 10:25 AM
Posts: 5,539

## Re: SGPanel : one color per graphic

With SAS 9.3, use an attribute map and specufy the same variable for panel and groups, as in the following example :

data test;
do mean= 5, 10;
do i = 1 to 100;
x = rand("Poisson", mean);
output;
end;
end;
run;

data myattrmap;
input ID \$ value \$ linecolor \$ fillcolor \$;
datalines;
myid  5  blue blue

myid  10 orange orange

;

proc sgpanel data=test dattrmap=myattrmap;
panelby mean;
hbar x / group=mean attrid=myid;
run;

PG

PG
Super User
Posts: 13,583

## Re: SGPanel : one color per graphic

The attribute map is optional, it basically allows you designate the colors instead of using style defaults for this application. Which is good for me as I'm running 9.2 and attribute maps aren't supported.

The legend may not mean much with this approach. If you don't want it add the NOAUTOLEGEND option to the proc statement.

Occasional Contributor
Posts: 9

## Re: SGPanel : one color per graphic

Thank you very much !! It was the option "group" ! Your help was very important for me thanks again !

🔒 This topic is solved and locked.