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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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
  • 2 replies
  • 3520 views
  • 0 likes
  • 2 in conversation