New SAS User

Completely new to SAS or trying something new with SAS? Post here for help getting started.
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Fara_I
Fluorite | Level 6

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!

 

 

1.jpg

2.jpg

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;

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

Go for

 

proc sgplot data=auto;
VBAR sum_dices / stat=percent;

run;

PG

View solution in original post

2 REPLIES 2
PGStats
Opal | Level 21

Go for

 

proc sgplot data=auto;
VBAR sum_dices / stat=percent;

run;

PG
ballardw
Super User

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.

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 2224 views
  • 0 likes
  • 3 in conversation