BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Sandeep77
Lapis Lazuli | Level 10

Hi all,

I have a sample data set and I want to sum the current_balance of same icustomerid. For e.g. if there are two debt_codes with one icustomerid then I would like to see one icustomerid with the total current_balance. I am trying to find the total balance for each icustomerid. Here is the sample dataset.

Data Test;
infile cards expandtabs;
input rep_code $ debt_code client_code $ Current_balance Balance_banding $ icustomerid;
datalines ;
168 245442736 3G073 47.57 £40-50 490
168 284369295 SUL007 7.79 £0-10 490
122 379059801 CAPONE150 276.21 £50+ 1234
122 379021629 CAPONE150 625.88 £50+ 1234
122 401458237 VANQUIS199 2862.77 £50+ 1234
122 396978322 EON067 252.35 £50+ 1234
168 441317245 SHOPDRCT1063 271.29 £50+ 125
;
run;
Can you please suggest the correct way?

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

This is a job for PROC SUMMARY!

 

proc summary data=test nway;
    class icustomerid;
    var current_balance;
    output out=want sum=;
run;
--
Paige Miller

View solution in original post

3 REPLIES 3
PaigeMiller
Diamond | Level 26

This is a job for PROC SUMMARY!

 

proc summary data=test nway;
    class icustomerid;
    var current_balance;
    output out=want sum=;
run;
--
Paige Miller
Sandeep77
Lapis Lazuli | Level 10
Thank you. It worked. Just wanted to add in it that what can I do if I want to add all the columns from the previous table to this test table? For e.g. we use select * to get all the variables from the previous dataset.
PaigeMiller
Diamond | Level 26

@Sandeep77 wrote:
Just wanted to add in it that what can I do if I want to add all the columns from the previous table to this test table? For e.g. we use select * to get all the variables from the previous dataset.

I don't know what you mean. Please explain further. Provide data examples and desired output. 

--
Paige Miller

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 590 views
  • 1 like
  • 2 in conversation