I have a deck of cards using the following data step.
How can I mix-up the cards in the dataset so that I can play 21?
data cards(keep=card suit c2);
do c1= 1 to 4;
if c1=1 then suit='C';
else if c1=2 then suit='D';
else if c1=3 then suit='H';
else if c1=4 then suit='S';
do c2= 1 to 13;
card=c2||suit;
output;
end;
end;
run;
data cards;
length card $3;
do suit = "C", "D", "H", "S";
do c2= 1 to 13;
card=cats(c2,suit);
output;
end;
end;
run;
proc sql;
create table shuffled as select * from cards order by rand("uniform");
quit;
data cards;
length card $3;
do suit = "C", "D", "H", "S";
do c2= 1 to 13;
card=cats(c2,suit);
output;
end;
end;
run;
proc sql;
create table shuffled as select * from cards order by rand("uniform");
quit;
PG
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Registration is open
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss. Register now and lock in 2025 pricing—just $495!