BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Godzilla_Hat
Obsidian | Level 7

SAS 2.png

 

This is what I have so far.

Data roll;
MyMoney=100;
	Die1 = ceil(6*ranuni(-1));
	Die2 = ceil(6*ranuni(-1));
sum = Die1+Die2;
if sum > 9 then MyMoney + 5;
else if sum < 9 then MyMoney - 2.50;


Run;

proc print data=roll;
run;
1 ACCEPTED SOLUTION

Accepted Solutions
ChrisHemedinger
Community Manager

How about something like this?

 

 

 

data RandInt;
length die1 8 die2 8 winnings 8 balance 8;
/* streaminit for reproducible sequence, comment out for different results */
call streaminit(123); 
retain balance 100;
do i = 1 to 100;
   die1 = rand("Integer", 1, 6);  /* requires SAS 9.4M5 or later */
   die2 = rand("Integer", 1, 6);  
   winnings = ifn(die1+die2>=9,5,-2.50);
   balance+winnings;
   output;
end;
drop i;
run;

 

 

ChrisHemedinger_0-1634249030927.png

 

Edit:

At first I had payout when the total > 9 only, and that's a sucker's game. But corrected to >= 9 and it seems better.

Check out SAS Innovate on-demand content! Watch the main stage sessions, keynotes, and over 20 technical breakout sessions!

View solution in original post

5 REPLIES 5
PaigeMiller
Diamond | Level 26

Are you asking for help?

--
Paige Miller
ChrisHemedinger
Community Manager

How about something like this?

 

 

 

data RandInt;
length die1 8 die2 8 winnings 8 balance 8;
/* streaminit for reproducible sequence, comment out for different results */
call streaminit(123); 
retain balance 100;
do i = 1 to 100;
   die1 = rand("Integer", 1, 6);  /* requires SAS 9.4M5 or later */
   die2 = rand("Integer", 1, 6);  
   winnings = ifn(die1+die2>=9,5,-2.50);
   balance+winnings;
   output;
end;
drop i;
run;

 

 

ChrisHemedinger_0-1634249030927.png

 

Edit:

At first I had payout when the total > 9 only, and that's a sucker's game. But corrected to >= 9 and it seems better.

Check out SAS Innovate on-demand content! Watch the main stage sessions, keynotes, and over 20 technical breakout sessions!
ballardw
Super User

Still a suckers game or at least not not for me.

Expected winnings per play, assuming fair dice, is -$0.41666666...

If you end up with more than 58.3333.... at the end of 100 plays you beat the house (a bit).

ballardw
Super User

@Godzilla_Hat wrote:

SAS 2.png


Why did you call this a "coin flip"? There are more than two outcomes per die and coins, barring the "lands on edge" event typically have only 2 outcomes.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 627 views
  • 0 likes
  • 4 in conversation