BookmarkSubscribeRSS Feed
BillB
Fluorite | Level 6

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.

Example:

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.

3 REPLIES 3
ballardw
Super User

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=;

run;

BillB
Fluorite | Level 6

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

TomKari
Onyx | Level 15

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.

  Tom

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 2891 views
  • 0 likes
  • 3 in conversation