BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Ngo99
Fluorite | Level 6
I am trying to create a graph, however, the discretemax has been reached. I have attached my code in the post. May I please have help how to increase the discretemax, where do I place it in the code ?
 
WARNING: BARCHARTPARM statement will not be drawn because the DISCRETEMAX threshold has been reached. You can set DISCRETEMAX=8,500
on the ODS GRAPHICS statement to draw the plot.
 
this is my code :
Ods graphics on;
proc freq data=WORK.IMPORT order=freq;
Tables ID/ plots=freqplot (type=bar scale=percent);
run;
Ods graphics off;
 
1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

Hello @Ngo99 and welcome to the SAS Support Communities!

 

Before you try to increase the DISCRETEMAX= option (ods graphics on / discretemax=...;) far beyond the default of 1000 (which SAS has set for a reason), I would recommend that you reconsider your TABLES statement. How many observations does WORK.IMPORT have? Use PROC CONTENTS to find out:

proc contents data=import;
run;

 

Does the output show something like this?

The CONTENTS Procedure

Data Set Name        WORK.IMPORT                   Observations          8500
Member Type          DATA                          Variables             ...
...

Or is the number of observations greater than 8500 and it's plausible to expect varying numbers of observations per ID? Then run the two PROC FREQ steps below as a preparation:

proc freq data=import noprint;
tables id / out=frq;
run;

proc freq data=frq;
tables count;
run;

This will show you how many IDs occur only once (COUNT=1), twice (COUNT=2), etc. Look at the last row of the frequency table. The value in column "Cumulative Frequency" (is it 8500?) is the number of vertical bars your original FREQPLOT request would generate. Compare this to your horizontal screen resolution. Obviously, even a "4K" monitor with a resolution of 3840 pixels across couldn't display 8500 separate bars at the same time, not to mention the massively overlapping 8500 tick mark labels of the x-axis.

 

Most likely you really want to use a different variable than ID with fewer distinct values in the TABLES statement or apply a format to variable ID that maps individual IDs to larger groups.

 

You can also create a preliminary plot from a small subset of WORK.IMPORT

proc freq data=WORK.IMPORT(obs=200) order=freq;
tables ID/ plots=freqplot (type=bar scale=percent);
run;

and then increase the number of observations (200) carefully, envisioning what the graph would look like with more and more observations (and thus vertical bars) included.

View solution in original post

4 REPLIES 4
PaigeMiller
Diamond | Level 26

You need to set the options in ODS GRAPHICS properly.

 

As it says: "You can set DISCRETEMAX=8,500 on the ODS GRAPHICS statement to draw the plot."

 

You need to do this before you create the plot.

--
Paige Miller
FreelanceReinh
Jade | Level 19

Hello @Ngo99 and welcome to the SAS Support Communities!

 

Before you try to increase the DISCRETEMAX= option (ods graphics on / discretemax=...;) far beyond the default of 1000 (which SAS has set for a reason), I would recommend that you reconsider your TABLES statement. How many observations does WORK.IMPORT have? Use PROC CONTENTS to find out:

proc contents data=import;
run;

 

Does the output show something like this?

The CONTENTS Procedure

Data Set Name        WORK.IMPORT                   Observations          8500
Member Type          DATA                          Variables             ...
...

Or is the number of observations greater than 8500 and it's plausible to expect varying numbers of observations per ID? Then run the two PROC FREQ steps below as a preparation:

proc freq data=import noprint;
tables id / out=frq;
run;

proc freq data=frq;
tables count;
run;

This will show you how many IDs occur only once (COUNT=1), twice (COUNT=2), etc. Look at the last row of the frequency table. The value in column "Cumulative Frequency" (is it 8500?) is the number of vertical bars your original FREQPLOT request would generate. Compare this to your horizontal screen resolution. Obviously, even a "4K" monitor with a resolution of 3840 pixels across couldn't display 8500 separate bars at the same time, not to mention the massively overlapping 8500 tick mark labels of the x-axis.

 

Most likely you really want to use a different variable than ID with fewer distinct values in the TABLES statement or apply a format to variable ID that maps individual IDs to larger groups.

 

You can also create a preliminary plot from a small subset of WORK.IMPORT

proc freq data=WORK.IMPORT(obs=200) order=freq;
tables ID/ plots=freqplot (type=bar scale=percent);
run;

and then increase the number of observations (200) carefully, envisioning what the graph would look like with more and more observations (and thus vertical bars) included.

WarrenKuhfeld
Ammonite | Level 13

A bit of history in case anyone is interested: When we first developed ODS Graphics and made procedures produce plots when ODS Graphics was enabled, ODS Graphics was disabled by default. A few releases later, the VP of R&D near the end of a release cycle suddenly decreed that ODS Graphics would be changed to be enabled by default. This left us with a problem. Some analyses that would have run fine with large data sets--one of many examples is data sets with many BY groups--with ODS Graphics disabled, and would have worked fine in the preceding decades, might suddenly produce hundreds (or thousands or tens of thousands) of graphs, totally bogging down the analysis. So we scrambled to make some graphs that were produced by default when ODS Graphics was enabled no longer the default. Other graphs, we disabled by default when the number of observations or some other threshold was exceeded. Then we had to provide options to give the user a way to enable graphs. If we had not had to switch from a default of disabled to a default of enabled, we would have done things differently. I was a SAS/STAT developer who worked closely with the ODS Graphics group. The work on ODS and then especially ODS Graphics were the most exciting times in my long tenure at SAS.

Ngo99
Fluorite | Level 6
Thank you so much, this helped me 🙂 @FreelanceReinhard

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 3066 views
  • 6 likes
  • 4 in conversation