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;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!

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
  • 4 replies
  • 1484 views
  • 1 like
  • 3 in conversation