SAS Software for Learning Community

Welcome to the exclusive online community for all SAS learners.
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-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

SAS Training: Just a Click Away

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

Browse our catalog!

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