BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ftahsin
Obsidian | Level 7

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.

 

1 ACCEPTED SOLUTION

Accepted Solutions
smantha
Lapis Lazuli | Level 10
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;

View solution in original post

2 REPLIES 2
smantha
Lapis Lazuli | Level 10
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;
ftahsin
Obsidian | Level 7
Thanks! I tried this code and it worked!

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 482 views
  • 2 likes
  • 2 in conversation