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 observations
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;
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.
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.
*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;
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;
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!Select SAS Training centers are offering in-person courses. View upcoming courses for: