Accounts table has 4 records entered in July 2016.
Accounts | ||
ID | Entry date | Orignal_Debt |
A100 | 15/7/16 | $20 |
A101 | 22/7/16 | $25 |
A102 | 25/7/16 | $10 |
A103 | 28/7/16 | $5 |
Payment table
Paid | ||
ID | Paid date | Paid |
A100 | 17/7/16 | $22 |
A100 | 17/7/16 | -$22 |
A100 | 19/7/16 | $20 |
A101 | 4/8/16 | $30 |
A102 | 31/7/16 | $2 |
A102 | 1/8/16 | $2 |
A102 | 2/8/16 | $2 |
A102 | 3/8/16 | $2 |
A102 | 4/8/16 | $2 |
A102 | 5/8/16 | $2 |
A103 | 1/9/16 | $5 |
A103 | 2/9/16 | $10 |
A103 | 2/9/16 | -$10 |
Final Output:
Output | ||||||
Paid Month | Paid Month | Paid Month | ||||
Month-Year | Accounts Entered | Original Debt | Jul-16 | Aug-16 | Sep-16 | Total Paid |
Jul-16 | 4 | $60 | $22 | $33 | $5 | $60 |
Some points to be noted:
1. From the payments table, we can see that A101 has paid 5$ extra that does not need to be considered.
2. A102 has done payment in installments but mistakenly paid 2$ extra that does not need to be considered.
3. For ID A100 and A103, there were some records that were mistakenly recorded that has to be avoided (reversal of values).
Any help would be appreciated.
Hi Norman,
I want the accounts and payment table summarized into below table.
Month-Year | Accounts Entered | Original Debt | Jul-16 | Aug-16 | Sep-16 | Total Paid |
Jul-16 | 4 | $60 | $22 | $33 | $5 | $60 |
Jul-16, Aug-16 and Sep-16 are paid months.
You haven't clearly specified how you determine which record to exclude in the case of overpayment.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.