turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- SAS/GRAPH and ODS Graphics
- /
- Descending values of the vertical axis and positi...

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

10-05-2009 08:52 AM

Hi to all,

I've got the 2 following questions:

1) I've to plot a gchart, where the hbar variable is numeric, and I've applied a format to show it. However, I need to put the values in descending order, but I couldn't find any way to do it (I cannot specify all the values, because the format does regroup the values)...any idea?

2) I've been asked to put the vertical legend in the center of the graph, where the value is 0...I should use the annotate, but how?

Thanks

Daniele

I've got the 2 following questions:

1) I've to plot a gchart, where the hbar variable is numeric, and I've applied a format to show it. However, I need to put the values in descending order, but I couldn't find any way to do it (I cannot specify all the values, because the format does regroup the values)...any idea?

2) I've been asked to put the vertical legend in the center of the graph, where the value is 0...I should use the annotate, but how?

Thanks

Daniele

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

10-05-2009 11:01 AM

Hi:

Look at the DESCENDING option of the HBAR statement:

http://support.sas.com/documentation/cdl/en/graphref/61884/HTML/default/gchart-bar.htm

It will order the bars in descending order. For example, both HBAR statements will generate bars in descending order:

[pre]

proc gchart data=sashelp.class;

hbar age /levels=6 descending ;

hbar age / discrete descending;

run;

quit;

[/pre]

I'm not sure I understand what you mean by vertical legend?? You mean the position of the statistics?? Or are you using SUBGROUP= that has a legend??? The SUBGROUP legend can be controlled by the LEGEND statement.

However, for more information about using the ANNOTATE facility, refer to these sites for a place to start with Annotate:

http://support.sas.com/documentation/cdl/en/graphref/61884/HTML/default/annodata-ov.htm

http://support.sas.com/documentation/cdl/en/graphref/61884/HTML/default/a002093540.htm#ganvbar-ex http://support.sas.com/documentation/cdl/en/graphref/61884/HTML/default/annotate_annotate.htm

http://www2.sas.com/proceedings/sugi31/085-31.pdf

http://www2.sas.com/proceedings/sugi31/108-31.pdf

http://analytics.ncsu.edu/sesug/2001/P-606.pdf

http://www.nesug.org/Proceedings/nesug97/infviz/mendelso.pdf

http://www.lexjansen.com/mwsug/2007/DataVisualization/D04-2007.pdf

And, this site has a wealth of SAS/GRAPH and ANNOTATE examples:

http://robslink.com/SAS/Home.htm

cynthia

Look at the DESCENDING option of the HBAR statement:

http://support.sas.com/documentation/cdl/en/graphref/61884/HTML/default/gchart-bar.htm

It will order the bars in descending order. For example, both HBAR statements will generate bars in descending order:

[pre]

proc gchart data=sashelp.class;

hbar age /levels=6 descending ;

hbar age / discrete descending;

run;

quit;

[/pre]

I'm not sure I understand what you mean by vertical legend?? You mean the position of the statistics?? Or are you using SUBGROUP= that has a legend??? The SUBGROUP legend can be controlled by the LEGEND statement.

However, for more information about using the ANNOTATE facility, refer to these sites for a place to start with Annotate:

http://support.sas.com/documentation/cdl/en/graphref/61884/HTML/default/annodata-ov.htm

http://support.sas.com/documentation/cdl/en/graphref/61884/HTML/default/a002093540.htm#ganvbar-ex http://support.sas.com/documentation/cdl/en/graphref/61884/HTML/default/annotate_annotate.htm

http://www2.sas.com/proceedings/sugi31/085-31.pdf

http://www2.sas.com/proceedings/sugi31/108-31.pdf

http://analytics.ncsu.edu/sesug/2001/P-606.pdf

http://www.nesug.org/Proceedings/nesug97/infviz/mendelso.pdf

http://www.lexjansen.com/mwsug/2007/DataVisualization/D04-2007.pdf

And, this site has a wealth of SAS/GRAPH and ANNOTATE examples:

http://robslink.com/SAS/Home.htm

cynthia

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

10-05-2009 12:02 PM

Dear Cynthia,

I've tried the descending option, but I believe it works with the sumvar variable, and not the hbar one (in fact, I get some weird ordered diagram, but which is ordered by the sum of the positive values and negative values of the sumvar variable)...I'm pretty sure of the format I'm using, since it's quite simple...

Thanks

Daniele

I've tried the descending option, but I believe it works with the sumvar variable, and not the hbar one (in fact, I get some weird ordered diagram, but which is ordered by the sum of the positive values and negative values of the sumvar variable)...I'm pretty sure of the format I'm using, since it's quite simple...

Thanks

Daniele

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

10-05-2009 11:44 AM

Daniele;

Based on your vertical axis question, It seems that you have negative and positive values. Proc GChart HBar will automaitically place the vertical axis at zero.

Example below;

data a;

input a $ b;

cards;

a 1

b -1

c 5

d -1

;

run;

proc gchart;

hbar a/sumvar=b;

run;

quit;

Based on your vertical axis question, It seems that you have negative and positive values. Proc GChart HBar will automaitically place the vertical axis at zero.

Example below;

data a;

input a $ b;

cards;

a 1

b -1

c 5

d -1

;

run;

proc gchart;

hbar a/sumvar=b;

run;

quit;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

10-05-2009 12:03 PM

Dear Bill,

thank you for your kind answer, but I believe I didn't express myself correctly: what I want is the legend of the vertical axes in the center of the graph (normally is on the left, since this is a hbar graph). Is it possible?

Thanks

Daniele

thank you for your kind answer, but I believe I didn't express myself correctly: what I want is the legend of the vertical axes in the center of the graph (normally is on the left, since this is a hbar graph). Is it possible?

Thanks

Daniele

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

10-05-2009 12:42 PM

If the axis values are already known, the simpliest approach it to specify the values on the MIDPOINTS= option in descending order. If they are no known, there are some techniques for generating this midpoint list dynamically using a macro.

Thanks!

Dan

Thanks!

Dan

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

10-05-2009 01:29 PM

Hi Dan,

I'm not sure of what you have explained on your post...how I should use midpoints?

Let me explain my dataset: I've got values for all the range of different ages from 0 to over 80 years, and I've to plot the values on a hbar diagram, where:

1) I've applied a format for the age, which groups the ages in 5 years segments (0-4 years, over 80 years old, and so on)

2) I'd like to show this diagram in this order:

80 years and over old

75 to 79 old

...

...

0 to 4 years old

3) This legend (which are the ages formatted) should be pun in the center of the graph, where tha value is 0 (the fact is that I've got also negative values, and the legend is at the left of the negative).

Thanks

Daniele

I'm not sure of what you have explained on your post...how I should use midpoints?

Let me explain my dataset: I've got values for all the range of different ages from 0 to over 80 years, and I've to plot the values on a hbar diagram, where:

1) I've applied a format for the age, which groups the ages in 5 years segments (0-4 years, over 80 years old, and so on)

2) I'd like to show this diagram in this order:

80 years and over old

75 to 79 old

...

...

0 to 4 years old

3) This legend (which are the ages formatted) should be pun in the center of the graph, where tha value is 0 (the fact is that I've got also negative values, and the legend is at the left of the negative).

Thanks

Daniele

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

10-05-2009 01:36 PM

It has been a long time, but isn't that what the ORIGIN= option on the axis statement does?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

10-05-2009 01:40 PM

Hi Flip,

maybe I'm using wrongly the origin option, but it doesn't only move the legend, but it also stretches the diagram...at the point that it doesn't put the legend inside the graph

maybe I'm using wrongly the origin option, but it doesn't only move the legend, but it also stretches the diagram...at the point that it doesn't put the legend inside the graph

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

10-05-2009 01:42 PM

Like I said it has been a while since I did graphics. You may want to annotate it.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

10-05-2009 04:01 PM

Hey Daniele,

What do you get if you add this option to your HBAR statement:

midpoints=(80 to 0 by -5)

-- Dan

What do you get if you add this option to your HBAR statement:

midpoints=(80 to 0 by -5)

-- Dan

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

10-05-2009 09:24 PM

I don't see how you can avoid replacing the format by a hard-coded age that is the same for each group.

You can then use the midpoints option to force the order.

>I've been asked to put the vertical legend ...

You mean the axis label?

You can then use the midpoints option to force the order.

>I've been asked to put the vertical legend ...

You mean the axis label?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

10-07-2009 03:53 AM

Hi to all,

for the first problem, I've solved by proc tabulating first with the format, and outputting the results in a dataset, that I've used with the proc gchart. In this way I've got one observation for class, and it's easy to order it as I want.

For the second point...yes Chris, I mean the axis1 legend...

Thanks

Daniele Edit: no, I was wrong, I meant the label

Message was edited by: Daniele Tiles

for the first problem, I've solved by proc tabulating first with the format, and outputting the results in a dataset, that I've used with the proc gchart. In this way I've got one observation for class, and it's easy to order it as I want.

For the second point...yes Chris, I mean the axis1 legend...

Thanks

Daniele Edit: no, I was wrong, I meant the label

Message was edited by: Daniele Tiles

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

10-07-2009 09:00 PM

This should get you started:

[pre]

data T;

set SASHELP.CLASS;

AGE+-13;

run;

data ANNO;

XSYS = '5'; * X coordinates use % of graphics output area ;

YSYS = '2'; * Y coordinates use data values ;

FUNCTION = 'label'; * I want to write a string;

TEXT = 'My label'; * This is the string;

X = 5; * Write at position X=5 (% of graphics output area);

Y = 0; * Write at Y=O (data value);

run;

axis1 label=(c=red 'free up space, should be white' );

proc gchart data=T annotate=ANNO;

hbar AGE / discrete nostats maxis=axis1;

run;

quit;

[pre]

data T;

set SASHELP.CLASS;

AGE+-13;

run;

data ANNO;

XSYS = '5'; * X coordinates use % of graphics output area ;

YSYS = '2'; * Y coordinates use data values ;

FUNCTION = 'label'; * I want to write a string;

TEXT = 'My label'; * This is the string;

X = 5; * Write at position X=5 (% of graphics output area);

Y = 0; * Write at Y=O (data value);

run;

axis1 label=(c=red 'free up space, should be white' );

proc gchart data=T annotate=ANNO;

hbar AGE / discrete nostats maxis=axis1;

run;

quit;