Desktop productivity for business analysts and programmers

How to get a subset of "Unique" Values

Posts: 42

How to get a subset of "Unique" Values

I have a data subset with acct numbers and curency amounts. There are multiple acct numbers with different currency values.

I want to obtain a subset of the acct numbers (Unique numbers) with their currency values summed e.g.


Here is what I have

Acct Number     Value

1111                    $10

1111                    $5

1111                    $20

2222                    $5

2222                    $15

Here is what I want

Acct Number     Value

1111                    $35

2222                    $20

Total                    $55

I want to be able to do this without programming since I'm still a "Novice" user.

Super User
Posts: 13,941

Re: How to get a subset of "Unique" Values

If the data is in a SAS data set named have, assuming the acct number variable name is account:

proc means data=have sum nway;

     class account;

     var value;

/* if you want to redirect the output to another data set add this line*/

     output out=newdataset  /sum=;


Posts: 42

Re: How to get a subset of "Unique" Values

I'm still new to E.G. and was hoping to get a non-programming solution.

Posts: 1,334

Re: How to get a subset of "Unique" Values

Believe it or not, you can get exactly that code using the EG visual tools.

Use the Describe | Summary Statistics task.

Put the variable for "Acct Number" into Classification Variables, and the variable for "Value" into Analysis Variables.

On the Statistics | Basic tab, click Sum, and unclick the others.

On Results, you have a few choices. Try playing around with "Show Statistics", which will create the output in a report format, and "Save statistics to a data set", which will do exactly that. Also, if you pick "N-way only", you'll only get summarization by Acct Number; if you pick "All ways", you'll also get a grand total.

Give it a try, and check out the help topics.


Ask a Question
Discussion stats
  • 3 replies
  • 3 in conversation