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.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.