Data visualization with SAS programming

Fitting all values on Dot plot

Reply
Contributor
Posts: 21

Fitting all values on Dot plot

Hello All,

In 9.2 when there are too many values of the categorical variable for a dot plot to display, then it thins them out. I thought for sure that there was an option in SAS 9.3 that forced all of the values to be displayed, but I can't find it. Was I dreaming that? Can someone point me to the option, please?

Thanks,

Chuck

Grand Advisor
Posts: 9,740

Fitting all values on Dot plot

Might helpt to give the code you're currently using to create the plot as well as any option statements in effect.

Contributor
Posts: 21

Fitting all values on Dot plot

Hi ballardw,

Thanks for the response. Sure, it might help people to see what I'm talking about. Here's example code, but take any dotplot where there are too many categorical values to fit on the vertical axis.

proc sgplot data=sashelp.cars;

    dot make;

run;

You'll see right off the bat that Acura and BMW are not shown on the vertical axis. The procedure is THINning the values on the axis. I thought for the life of me that there was an option to show all the values, in this case the MAKE's of the cars. Of course, now I can't find it. Maybe it doesn't exist.

Thanks again,

Chuck

Esteemed Advisor
Posts: 6,890

Fitting all values on Dot plot

Would incrasing the resolution correct the problem?  e.g.:


gsubmit "ods html image_dpi=600;"

Contributor
Posts: 21

Fitting all values on Dot plot

Hi art297,

Thanks for the response. It might, but that's not the point. I'm looking to see if a particular option exists. Thanks, though.

Respected Advisor
Posts: 4,606

Fitting all values on Dot plot

On the X axis you can specify a FITPOLICY to improve things. This is not available on the Y axis. To see all the values, you may decrease the font size of the tick values, as in :

proc sgplot data=sashelp.cars;

    dot make;

yaxis valueattrs=(size=6);

run;

PG

PG
Contributor
Posts: 21

Fitting all values on Dot plot

Thanks PGStats.

Respected Advisor
Posts: 4,606

Fitting all values on Dot plot

Another option which may or may not look better is to make a larger graph :

ods graphics / height=1200;

proc sgplot data=sashelp.cars;
    dot make;
*yaxis valueattrs=(size=6);
run;

PG

PG
SAS Super FREQ
Posts: 3,232

Fitting all values on Dot plot

Yes. This is what I would do.

Contributor
Posts: 21

Fitting all values on Dot plot

Well, I'll pick this as a helpful answer in case others come here because of the title, and I certainly appreciate the effort in trying to solve the problem. Thank you very much.

However, I don't think I was clear enough in stating the problem. I know the other work arounds to the problem, I was trying to determine if the developers had incorporated a feature that handled it automatically. It was a "Yes, it's ____" or "No, you're crazy" type of answer. I'll be giving a HOW at SGF and if that option is there, then I wanted to note that. I was told there was, I thought I saw it, but now I can't find it. My conclusion is that I am crazy, at least slightly. Smiley Happy

The work arounds provided are okay, but they're not great. They run into the same problem that I think a built-in option would have, which is the same problem the default behavior is trying to solve. When there's that many values to the categorical variable, there's just not enough space to show them all well. Both of the options PGStats gives change the space needed (font size option) relative to the space available (height). Both of those, and I suspect almost every solution, make it difficult to read the values when you fit the plot into a typically-sized space.

Thinking some more about it, I wonder if there's a way to put the "other" categorical values, in this case "Acura" and "BMW" on the Y2AXIS? Nothing comes to mind right off, though maybe with GTL. Doing so would reduce the horizontal space now. It may be too much if the values are long on both sides, such as "Mercedes-Benz," but maybe not. I'll see what I can figure out.

If anyone has suggestions on how to put the extra values on the Y2AXIS, then I'm open.

Thanks again everyone.

Esteemed Advisor
Posts: 6,890

Fitting all values on Dot plot

Chuck, FWIW, PGStats first suggestion of using:

yaxis valueattrs=(size=6);

is an option that has only been available since 9.3

This doesn't confirm or reject the hypothesis of craziness .. I'll leave that one for you to decide.

Contributor
Posts: 21

Fitting all values on Dot plot

LOL! Thanks Art.

Respected Advisor
Posts: 4,606

Fitting all values on Dot plot

Last but not least, you may have the option to split your data onto multiple graphs:

ods graphics / reset;

proc sort data=sashelp.cars out=cars; by origin; run;

proc sgplot data=cars uniform=xscale;
by origin;
    dot make;
*yaxis valueattrs=(size=6);
run;

Good luck.

PG

PG
SAS Employee
Posts: 963

Fitting all values on Dot plot

If there's not a good way with SGplot, perhaps a work-around would be to use GPlot ?

The traditional SAS/Graph procs tend to scrunch the axis tickmark values closer together (even to the point of overlapping), rather than thinning them. - ie, they give the user exactly what they ask for and let the user look at it and manually decide if they need to take action and do it differently.

proc sql;
create table foo as
select unique make, count(*) as count
from sashelp.cars
group by make
order by make;
quit; run;

symbol value=dot height=1 color=black;
proc gplot data=foo;
plot make*count=1 / autovref cvref=graydd;
run;

Contributor
Posts: 21

Fitting all values on Dot plot

Good suggestion. Thanks. Except that the HOW is on ODS Graphics and the syllabus calls for me to spend half an hour bashing SAS/Graph. I can't go back after that and say we have to use it. Smiley Happy

Post a Question
Discussion Stats
  • 19 replies
  • 774 views
  • 9 likes
  • 8 in conversation