Hello SAS Community,
I am working with a Medicaid dataset. I have enrollment and disenrollment month and year for children. The enrollment month and year is the month and year of birth for the child. I have the following data-
data have;
input ID begin :MONYY7. end :MONYY7.;
format begin MONYY7. end MONYY7.;
datalines;
6816494 FEB2006 MAY2006
6816515 JAN2006 OCT2008
6816515 DEC2008 JAN2019
6819880 FEB2006 JAN2019
6820127 JAN2006 MAR2014
;
run;
I want the following data-
But, I want it for 5 years past the baby's birth date/enrollment date. The example data below only show for 1 year past the birth/enrollment date.
data want;
input ID month $ year enroll;
datalines;
6816494 FEB 2006 1
6816494 MAR 2006 1
6816494 APR 2006 1
6816494 MAY 2006 1
6816494 JUN 2006 0
6816494 JUL 2006 0
6816494 AUG 2006 0
6816494 SEP 2006 0
6816494 OCT 2006 0
6816494 NOV 2006 0
6816494 DEC 2006 0
6816494 JAN 2007 0
6816515 JAN 2006 1
6816515 FEB 2006 1
6816515 MAR 2006 1
6816515 APR 2006 1
6816515 MAY 2006 1
6816515 JUN 2006 1
6816515 JUL 2006 1
6816515 AUG 2006 1
6816515 SEP 2006 1
6816515 OCT 2006 1
6816515 NOV 2006 1
6816515 DEC 2006 1
;
run;
Thank you so much. Your assistance with the code is appreciated.
data have;
input ID begin :MONYY7. end :MONYY7.;
format begin MONYY7. end MONYY7. ;
put begin = end = date9.;
do i = 0 to 59;
d = intnx('month',begin,i,'B');
year = year(d);
month = put(d,monname3.);
enroll = (d<= end);
output;
drop i d begin end;
end;
datalines;
6816494 FEB2006 MAY2006
6816515 JAN2006 OCT2008
6816515 DEC2008 JAN2019
6819880 FEB2006 JAN2019
6820127 JAN2006 MAR2014
;
run;
data have;
input ID begin :MONYY7. end :MONYY7.;
format begin MONYY7. end MONYY7. ;
put begin = end = date9.;
do i = 0 to 59;
d = intnx('month',begin,i,'B');
year = year(d);
month = put(d,monname3.);
enroll = (d<= end);
output;
drop i d begin end;
end;
datalines;
6816494 FEB2006 MAY2006
6816515 JAN2006 OCT2008
6816515 DEC2008 JAN2019
6819880 FEB2006 JAN2019
6820127 JAN2006 MAR2014
;
run;
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.