DATA Step, Macro, Functions and more

Data step

Reply
Occasional Contributor
Posts: 17

Data step

Hi All,

 

I have below sample data set and I would like to get the desire result as follows.

data test;

input A B C D;

cards;

10 9 13 10

7 7 9 8

6 7 6 8

2 3 3 4

3 4 6 6

6 7 6 7

8 7 7 7

9 8 11 10

9 9 9 9

;

run;

 

Reslt is as follows

ABCDCount
10913103
77983
67683
23343
34663
67674
87774
9811104
99994
Super User
Posts: 6,946

Re: Data step

And what is the logical rule for the intended result?

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super User
Posts: 10,516

Re: Data step

What are you "counting"?

Respected Advisor
Posts: 4,651

Re: Data step

Shouldn't the result be

 

A	B	C	D	Count
10	9	13	10	3
7	7	9	8	3
6	7	6	8	4
2	3	3	4	1
3	4	6	6	3
6	7	6	7	2
8	7	7	7	2
9	8	11	10	4
9	9	9	9	4
PG
Contributor
Posts: 37

Re: Data step

What is that you want to accomplish?

 

PROC Star
Posts: 7,363

Re: Data step

If your 'want' represents a card related scoring table, where a pair of numbers-3, and anything greater than 1 pair (e.g., 2 pairs, 3 of a kind, 4 of a kind or a straight=4), then you might want to simply modify the code offered at https://communities.sas.com/t5/SAS-Procedures/Allocating-Values-to-Poker-Hands/td-p/146459

 

It does all of the above, but was written to evaluate all possible poker hands and rank them according to the rules of poker, but you're only working with 4 cards, don't consider suit, and consider anything greater than a pair to be equal to 4.

 

Art, CEO, AnalystFinder.com

 

Ask a Question
Discussion stats
  • 5 replies
  • 188 views
  • 0 likes
  • 6 in conversation