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;
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;
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.
Are you asking for help?
Yes please
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;
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.
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).
@Godzilla_Hat wrote:
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.
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.