BookmarkSubscribeRSS Feed
LisaYIN9309
Obsidian | Level 7

I've come across this task using two dataset, I've simplified the issues in the two input tables:

 

What I want to figure out is:

a.  # of pregnancy episodes of women whose pregnancy start and end date both in 2015 and who also has no more than 45 days continuous enrollment gap in 2015(one single gap > 45 days counts as a gap, not accumulated gap)

b. # of pregnancy episodes of women whose has insurance from the 30 days prior to their pregnancy end towards their pregnancy end, and whose pregnancy end date is in year 2015, same 45 day gap rule.

 

 

First table has pregnancy start and end date (pregnancy_ID = 2 means this is this women's 2nd pregnancy episode)

PersonIDPregnancy_startPregnancy_endPregnancy_ID
14/16/20141/31/20151
16/1/201512/21/20152
22/12/201511/31/20151
31/1/20158/16/20151
43/1/201511/23/20151
52/3/20156/7/20151
510/12/20157/31/20162
64/1/201512/19/20151

 

second table has insurance start and end date

PersonIDInsurance_startInsurance_end
11/1/20141/6/2014
19/6/20145/3/2015
15/3/20151/1/2017
21/1/201410/1/2015
31/1/201412/31/2016
45/1/20143/6/2015
45/1/201512/31/2016
51/1/20141/1/2017
65/1/201411/31/2015

 

 

For task a, I can easily identify the first part, whose pregnancy start and end both in 2015, but the second part gets tricky. As shown in the second table, a women may have multiple insurance enrollment entries (they enrolled and dropped and re-enrolled), and merging both tables create a multiple to multiple merge, kind complex the problem....

 

For task b, it's easy to identify if they have insurance at the exact day of the 30 days prior, but I can't find a way to ensure the entire period is continuous enrolled.....

 

Thank you!

2 REPLIES 2
ChrisNZ
Tourmaline | Level 20

Please provide the expected output (and double check it is correct).

LisaYIN9309
Obsidian | Level 7

thank you for asking @ChrisNZ, the desired output is just two data point

-  # of women in task a.

- # of women in task b.

 

The reason why I didn't list a desired table is that I am not sure what is the best way to count it, to merge two datasets and then do it or satisfy the conditions separately in each dataset and then merge or never merge. The pregnancy dataset has more than 5000 observations and the enrollment dataset has something like 6000 (because one person can have multiple rows/multiple enrollment and drop enrollment), thus I feel a many to many merge will complex the problem.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 995 views
  • 0 likes
  • 2 in conversation