displaying negative data values on bars

Reply
Contributor
Posts: 30

displaying negative data values on bars

Hi,

When displaying data values(positive or negative) using BARS ( outside/inside), they get displayed on the top of the bar.

For positive values, its fine.... but for negative values, I wanted to display them at the bottom of the bar.  (as shown by arrow in below image)..

Is this possible  without using annotate?

negval.jpg


Contributor
Posts: 30

Re: displaying negative data values on bars


Hello experts,

No reply....  and  I am confused if my question is a valid one? :smileyconfused:

Super User
Posts: 10,538

Re: displaying negative data values on bars

First step would be to desribe how you are creating the current graph, especially with code. Answers likely differ if you are using classic graphing procs such as GCHART or GPLOT, the statistica graphics plots, SGPLOT or graphics template language.

Super User
Posts: 17,907

Re: displaying negative data values on bars

It's a valid question, but I don't see a way to do it without using annotate Smiley Sad. If you had all by the axis that might be easier, but to have positive at (top inside) and negative at (bottom inside).

Good luck Smiley Happy

Super Contributor
Posts: 543

Re: displaying negative data values on bars

One way would be to use PROC TEMPLATE (see code example below)

data have;

do i = -10 to 10 by 2;

    x = i;

    y = i* 2+x;

output;

end;

run;

proc template;

define statgraph labels;

dynamic X Y;

begingraph ;

   layout lattice ;

      layout overlay;

         barchart x = X y = Y / barlabel=true;

      endlayout;

   endlayout;

endgraph;

end;

run;

proc sgrender data = have template = labels;

dynamic X = "X" Y = "Y";

run;

Best of luck!

Contributor
Posts: 30

Re: displaying negative data values on bars

Thank you all for your replies..

I am using gchart and gbarline.

I tried using proc template... I get errors at words ..dynamic , begingraph.......

Super Contributor
Posts: 543

Re: displaying negative data values on bars

What kind of errors?

What SAS version are you using?

Just because the words are in red, it doesn't mean an error.

(just to clarify)

Also, the code I posted above has a missing ";" after the run statement that creates the data set have.

Ask a Question
Discussion stats
  • 6 replies
  • 339 views
  • 0 likes
  • 4 in conversation