ID MON18_01 MON18_02 MON18_03 MON18_04 MON18_05 MON18_06 MON18_07 MON18_08 MON18_09 MON18_10 MON18_11 MON18_12 MON19_01 MON19_02 MON19_03 MON19_04 MON19_05 MON19_06 MON19_07 MON19_08 MON19_09 MON19_10 MON19_11 MON19_12 MON20_01 MON20_02 MON20_03 MON20_04 MON20_05 MON20_06 MON20_07 MON20_08 enroll1 disenroll1 enroll2 disenroll2 enroll3 disenroll3
111111111 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 1 1 1 Jan-18 Feb-18 Mar-18 Oct-19 Jun-20 .
222222222 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Jan-18 Jul-18 Sep-18 .
3333333333 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Jan-18 .
I am trying to add dates based on columns MON18_01 represents January 2018 etc..
i need to add columns enroll and disenroll (enroll1 , disenroll1 , enroll2 , disenroll2 ,.....)
for data below id 1111111 enroll1 = jan 2018 and disenroll1 = feb 2018 , enroll2 = mar- 2018 disenroll2 = oct 2019 , enroll3 = jun 2020 and disenroll = ' '
I need to do that for all the IDs being able to find the zeros and ones and assign enrollment and dis-enrollment dates based on columns
sample data file attached
Most of us will not download Microsoft Office attachments as they can be a security threat. Better you should provide the data as SAS data step code (via these instructions: https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/)
I think it would also help if you showed us what the output would look like.
Are you able to re-shape your data? The answer to this (and many other) programming problems would be simple to get if your data looked more like this:
ID YEAR MONTH ENROLLED
You would need many observations per ID. If you were to do this, the programming techniques you would need to learn to process your data would be much more useful to you in future projects.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.