Hi All
Require help in building the SAS logic.
Below is an example data and using the first 5 columns as inputs, needs to produce last 3 columns.
Thanks for the help in advance.
AccountNo | TransactionDate | Amount | ReturnFlag | ReturnDate | Last7days_to_15Days_Counts | Last7days_to_15Days_Amount | Last7days_to_15Days_Average |
2 | 5-Dec-17 | 50 | . | ||||
2 | 6-Dec-17 | 100 | 1 | 14-Dec-17 | |||
2 | 7-Dec-17 | 150 | 1 | 12-Dec-17 | |||
2 | 8-Dec-17 | 200 | 1 | 16-Dec-17 | |||
2 | 15-Dec-17 | 250 | 1 | 16-Dec-17 | 2 | 250 | 125 |
2 | 16-Dec-17 | 300 | 1 | 17-Dec-17 | 2 | 250 | 125 |
@InnovativeMinds Asking for code favor is not bad or wrong? But what have you tried or at least attempted something ?
No, it's not bad asking for help. Do you think users come here without trying?
All that mark was asking is to show what you have tried and get help to fix or modify your solution. That's all and it didn't sound rude at all. I have been told that too in the past and more in a rude manner by many but i took that as an affirmative. And yes, many users do get here taking advantage of other's time. Unfortunately that happens all the time.
Do you only have a single record per day?
If so, PROC EXPAND with a CONVERT statement will do what you want. You may need to add a record for every day, but you can do that easily with PROC TIMESERIES.
If you need further help, please provide the code you've attempted thus far and your data, preferably as a data step.
This is a commonly asked question, so if you don't have SAS/ETS search for moving statistics via an array or DoW loop and you'll find many answers.
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.