I have the following code, and when I run it, it gives me the following output graph, but I want to adjust my histogram so that the x-axis shows the values of sum_dices from {2, 3, 4, …, 12} and the y-axis is the corresponding percent for each sum_dice (i.e {2.78, 5.56, 8.33, …, 2.78} ). I tried to do this by setting the binwidth to 1 but it did not really change anything to my understanding. I am new to SAS so I will appreciate any help you can provide me. Thank you!
CODE:
data auto;
do dice1= 1 to 6;
do dice2= 1 to 6;
sum_dices = sum(dice1, dice2);
output;
end;
end;
proc freq data = auto;
proc sgplot data = auto;
histogram sum_dices/ nbins = 10 binwidth = 1 showbins scale= count datalabel=percent;
run;
OUTPUT:
You have 11 bins, not 10.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.