Greetings, I have a big programming problem. The objective of my project is to calculate the loss of contracts in a certain period of months. My data is organized as follows (only two months appear, but it follows)
The idea is to filter the live contracts in month 1, and see if they die in the following months. A contract is live if it is less than 180 days past due. That is, by filtering this table for month 1, we have the following.
Then look in the following months the evolution of the contracts. That is, I create a loss table with the filters: Month > 1 and Delay >180 Getting the following
The problem is that my databases are corrupted and I can't wait for my client to give me clean ones. In my loss matrix, only contract F should appear, which presents a logical evolution of the delay. Contract B takes an illogical leap in the delay, and contract I did not even appear in the previous month.
So I need to create some kind of rule or filter that doesn't make me take these contracts for the construction of the loss matrix. So, my idea is to make the following rule: Only add the contract to the loss, if it exceeds 180 days, and also exists on the basis of the previous month with a delay difference of less than or equal to 31 days between Monthly Delay (x) and Monthly Delay (x-1).
That is, it cannot have logical jumps in the delay, nor can it suddenly appear from one month to another.
And the truth is that I have no idea how to do it. In pandas I would try to do a left join with flags and only add the contracts that appear in both instances with the 'both' flag and that have logical delay evolution. But in SAS it does not occur to me.
Sorry if the question is too long and the explanation is confusing. I appreciate your help in advance.
... View more