BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
chester2018
Obsidian | Level 7

Hi! I'm making a histogram of minutes of exercise in a week. Below is my graph and my code. I want to set up endpoints, so I can have a graph that makes sense. Or in other words, I want to have a histogram without the extreme observationscode.PNGhistogram.PNGoutliers.PNG

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

Read about how to use the BINWIDTH= option on the HISTOGRAM statement to define the bin width.

You can also use the MAX= option on the XAXIS statement to view only a subset of the histogram.

For example, the following statements truncate the range of the MPG_City variable in the Sashelp.Cars data and set the bin width to 2.

title "Zoom in on Lower Values of MPG_City";
title2 "Data Truncated by MPG <= 31";
proc sgplot data=Sashelp.cars;
   histogram MPG_City / binwidth=2 binstart=10;
   xaxis values=(10 to 30 by 2) max=31;  /* Optional: use VALUESHINT option */
run;

View solution in original post

4 REPLIES 4
ballardw
Super User

In SGPLOT if your provide an XAXIS statement with a values list that will truncate values.

Such as:

xaxis values=(0 to 600 by 100);

which would limit the X values used to a maximum of 600.

 

Please provide code as TEXT pasted into a text box opened on the forum with the </> icon. I am not going to retype your code from a picture. It is hard to make changes to pictures.

chester2018
Obsidian | Level 7

Thanks for this suggestion, but the graph pretty much combined all the values into one big column.  I also tried to make the upper limit 300. But then the output is zoom into the graph.

 

 

histogram.PNG

histogramzoom.PNG

 

 

*this is for the first histogram*
proc sgplot data=aerobics_v5;
histogram Aerobic_Min_Week;
xaxis values=(0 to 1000 by 20);
run;

*this is for the second histogram*
proc sgplot data=aerobics_v5;
histogram Aerobic_Min_Week;
xaxis values=(0 to 300 by 20);
run;
chester2018
Obsidian | Level 7
I guess bin sizes would help
Rick_SAS
SAS Super FREQ

Read about how to use the BINWIDTH= option on the HISTOGRAM statement to define the bin width.

You can also use the MAX= option on the XAXIS statement to view only a subset of the histogram.

For example, the following statements truncate the range of the MPG_City variable in the Sashelp.Cars data and set the bin width to 2.

title "Zoom in on Lower Values of MPG_City";
title2 "Data Truncated by MPG <= 31";
proc sgplot data=Sashelp.cars;
   histogram MPG_City / binwidth=2 binstart=10;
   xaxis values=(10 to 30 by 2) max=31;  /* Optional: use VALUESHINT option */
run;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 4 replies
  • 1741 views
  • 1 like
  • 3 in conversation