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

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;

1 ACCEPTED SOLUTION

Accepted Solutions
DanH_sas
SAS Super FREQ

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

2 REPLIES 2
DanH_sas
SAS Super FREQ

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;

Brigitte_sas
SAS Employee

Hi Dan,

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

Have a nice day,

Brigitte

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 4366 views
  • 0 likes
  • 2 in conversation