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.
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!
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.