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 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

From SAS Users blog
Want more? Visit our blog for more articles like these.
5 Steps to Your First Analytics Project Using SAS

For SAS newbies, this video is a great way to get started. James Harroun walks through the process using SAS Studio for SAS OnDemand for Academics, but the same steps apply to any analytics project.

Find more tutorials on the SAS Users YouTube channel.

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