Data visualization with SAS programming

How to change the colors in a waterfall chart?

Accepted Solution Solved
Reply
SAS Employee
Posts: 10
Accepted Solution

How to change the colors in a waterfall chart?

Hi there,

I work with SAS 9.3 and want to generate a waterfall chart with grouped data. I’m using proc template and sgrender.

The downwards bar I want to display with the red color, the ascending bar with the green color.

I want to use the statement “fillattrs=(COLOR=GREEN CONTRASTCOLOR=RED)” but I make something wrong, it don’t works….  :-(

Do you have an idea what’s wrong or circumvention for this problem?

Thank you very much for your help.

Brigitte

~~~~~~~~~~~~~~~~ code ~~~~~~~~~~~

data WORK.DATA_GRAPH;

     input MONAT_TXT $ KER_GESAMT_IST_AJ POSNEG;

datalines;

Jan2011 288425 1

Feb2011 -280884 0

Mar2011 652716 1

Apr2011 200244 1

May2011 27043 1

Jun2011 415841 1

Jul2011 -308976 0

Aug2011 -46304 0

Sep2011 474226 1

;

run;

proc template;

                define statgraph KER_GRAPH_WATERFALL ;

                begingraph / designheight = 600 designwidth = 1200 border = false;

                entrytitle _id='title' halign=left 'Jahresverlauf operatives Ergebnis' / textattrs=(weight=bold style=normal size=9 family='Arial');

                layout overlay;

                     waterfallchart category=MONAT_TXT response=KER_GESAMT_IST_AJ /

                           colorgroup=POSNEG fillattrs=(COLOR=GREEN CONTRASTCOLOR=RED)

                           barlabel=true dataskin=gloss

                           datalabelattrs=(color=BLACK style=NORMAL family='Arial' size=9)

                          

                     ;

                endlayout;

                endgraph;

           end;

          

proc sgrender data     = WORK.DATA_GRAPH

   template = KER_GRAPH_WATERFALL ;

run;


Accepted Solutions
Solution
‎01-10-2012 11:54 AM
SAS Super FREQ
Posts: 864

How to change the colors in a waterfall chart?

The way to do this is to use a discrete attributes map. It gives you the ability to assign attributes to specific values. Notice in the code below that I use the new ATTRVAR called SIGNVAR instead of the POSNEG variable for the COLORGROUP so that the map is used by the waterfall chart.

Hope this helps!

Dan

proc template;
  define statgraph KER_GRAPH_WATERFALL ;

  begingraph / designheight = 600 designwidth = 1200 border = false;

  discreteattrmap name="colorbysign";
     value '0' / fillattrs=(color=red);
     value '1' / fillattrs=(color=green);
  enddiscreteattrmap;

  discreteattrvar attrvar=signvar var=posneg attrmap="colorbysign";

  entrytitle _id='title' halign=left 'Jahresverlauf operatives Ergebnis' / textattrs=(weight=bold style=normal size=9 family='Arial');

  layout overlay;
     waterfallchart category=MONAT_TXT response=KER_GESAMT_IST_AJ / colorgroup=signvar
              barlabel=true dataskin=gloss datalabelattrs=(color=BLACK style=NORMAL family='Arial' size=9);

  endlayout;

  endgraph;

end;

View solution in original post


All Replies
Solution
‎01-10-2012 11:54 AM
SAS Super FREQ
Posts: 864

How to change the colors in a waterfall chart?

The way to do this is to use a discrete attributes map. It gives you the ability to assign attributes to specific values. Notice in the code below that I use the new ATTRVAR called SIGNVAR instead of the POSNEG variable for the COLORGROUP so that the map is used by the waterfall chart.

Hope this helps!

Dan

proc template;
  define statgraph KER_GRAPH_WATERFALL ;

  begingraph / designheight = 600 designwidth = 1200 border = false;

  discreteattrmap name="colorbysign";
     value '0' / fillattrs=(color=red);
     value '1' / fillattrs=(color=green);
  enddiscreteattrmap;

  discreteattrvar attrvar=signvar var=posneg attrmap="colorbysign";

  entrytitle _id='title' halign=left 'Jahresverlauf operatives Ergebnis' / textattrs=(weight=bold style=normal size=9 family='Arial');

  layout overlay;
     waterfallchart category=MONAT_TXT response=KER_GESAMT_IST_AJ / colorgroup=signvar
              barlabel=true dataskin=gloss datalabelattrs=(color=BLACK style=NORMAL family='Arial' size=9);

  endlayout;

  endgraph;

end;

SAS Employee
Posts: 10

How to change the colors in a waterfall chart?

Hi Dan,

thank you very much for this successful solution. I learned a lot !

Have a nice day,

Brigitte

Post a Question
Discussion Stats
  • 2 replies
  • 687 views
  • 0 likes
  • 2 in conversation