BookmarkSubscribeRSS Feed
ChuckK
Calcite | Level 5

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

19 REPLIES 19
ballardw
Super User

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

ChuckK
Calcite | Level 5

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

art297
Opal | Level 21

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


gsubmit "ods html image_dpi=600;"

ChuckK
Calcite | Level 5

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.

PGStats
Opal | Level 21

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
ChuckK
Calcite | Level 5

Thanks PGStats.

PGStats
Opal | Level 21

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
Rick_SAS
SAS Super FREQ

Yes. This is what I would do.

ChuckK
Calcite | Level 5

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.

art297
Opal | Level 21

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.

ChuckK
Calcite | Level 5

LOL! Thanks Art.

PGStats
Opal | Level 21

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
GraphGuy
Meteorite | Level 14

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;

ChuckK
Calcite | Level 5

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 19 replies
  • 2358 views
  • 9 likes
  • 8 in conversation