Hi,
I'm working with a dataset that looks something like below:
account | month_end | active_stat |
1 | 31-Jan-20 | yes |
1 | 29-Feb-20 | yes |
1 | 31-Mar-20 | yes |
2 | 31-Jan-20 | yes |
2 | 29-Feb-20 | no |
2 | 31-Mar-20 | no |
3 | 31-Jan-20 | no |
3 | 29-Feb-20 | no |
3 | 31-Mar-20 | yes |
Account field: unique account number
Month_end: date
active_stat: indicator showing whether an account is active or not during that month
I'd like to get help with creating a new column that returns active status of the accounts in the data sets in previous month. Below is example of the output i'd like to achieve, where prevmon_stat shows active status of the account in previous month.
account | month_end | active_stat | prevmon_stat |
1 | 31-Jan-20 | yes | |
1 | 29-Feb-20 | yes | yes |
1 | 31-Mar-20 | yes | yes |
2 | 31-Jan-20 | yes | |
2 | 29-Feb-20 | no | yes |
2 | 31-Mar-20 | no | no |
3 | 31-Jan-20 | no | |
3 | 29-Feb-20 | no | no |
3 | 31-Mar-20 | yes | no |
Thank you for your help!