- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I need to adjust my code so that I can plot the percentage column of sum_dices in my histogram, but when I run it I get the following output. So instead of plotting the count of each sum, I want to plot the percentage such as 2.78 for 2, 5.56 for 3, and so forth. I have tried adjusting the VBAR line but could not get it to display the values I want. I am fairly new to SAS so I appreciate any help you can provide me, thanks!
DATA auto;
INPUT dice1 dice2;
sum_dices = sum(dice1, dice2);
CARDS;
1 1
1 2
1 3
1 4
1 5
1 6
2 1
2 2
2 3
2 4
2 5
2 6
3 1
3 2
3 3
3 4
3 5
3 6
4 1
4 2
4 3
4 4
4 5
4 6
5 1
5 2
5 3
5 4
5 5
5 6
6 1
6 2
6 3
6 4
6 5
6 6
;
proc sgplot data=auto;
VBAR sum_dices;
proc freq data=auto;
run;
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Go for
proc sgplot data=auto;
VBAR sum_dices / stat=percent;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Here is a more efficient way to create your AUTOS data set:
DATA auto; do dice1= 1 to 6; do dice2= 1 to 6; sum_dices = sum(dice1, dice2); output; end; end; run;
Why do I say more efficient? Can change for 6-sided dice to any N-sided dice where N >= 1. Adding a third, forth or more dice is simple by just adding more do loops, one for each. You can easily examine differences involving more or different numbers of faces on dice.
Since 3 6-sided dice has 216 permutations that would be a lot of cards statements to get right.