I have three columns named ID, Month, and Year. My goal is to create a new column called "new_month."
The values for the "new_month" column will be determined based on a prompt that asks for a specific date. I will provide a date in response to the prompt. The values in the Month column that fall between the month of the prompted date and two months following that month should be assigned to the last month.
For example, if the prompted date is 08/01/2021, any values in the Month column that fall between 8 and 10 should be assigned the value 10. Similarly, values between 9 and 11 should be assigned 11, and values between 10 and 12 should be assigned 12. These assignments will be made in the calculated new_month column.
It's worth noting that there will be duplicated values for IDs because a single month, such as 10, may belong to multiple categories (10, 11, and 12). This duplication is intentional as I need to count the number of IDs from two months prior to my measuring period. The measuring periods, in this case, are 10, 11, and 12.
Initially, I considered using a CASE statement with multiple WHEN-THEN conditions. However, I discovered that if the first condition evaluates to TRUE, SAS will ignore the subsequent conditions.
I am using SAS EG. So, please keep this in mind when commenting. I would appreciate any assistance you can provide in implementing this logic.
... View more