Hello everyone,

I will appreciate an urgent help with how to go about this statistical issue. I want to determine the timing of recording of the substance use related diagnosis in relation to pregnancy using a hierarchical coding with the order as follows:
  1. During pregnancy
  2. ≤1yr before pregnancy
  3. ≤1yr after pregnancy
  4. >1yr before pregnancy
  5. >1yr after pregnancy

My data gives me conception date and delivery date. How do I generate 1-5 from these two variables.

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input str9(conception_date delivery_date)
"22jan2012" "21oct2012"
"22jan2012" "21oct2012"
"25jun2009" "08apr2010"
"13aug2008" "13may2009"
"16jul2015" "05may2016"
"25may2006" "08mar2007"
"25may2006" "08mar2007"
"25may2006" "08mar2007"
"06nov2010" "06aug2011"
"06nov2010" "06aug2011"
"05feb2013" "22oct2013"
"05feb2013" "22oct2013"
"15jun2011" "21mar2012"
"28feb2015" "14nov2015"
"26nov2015" "25aug2016"
"31dec2008" "23sep2009"
"31dec2008" "23sep2009"
"13sep2008" "13jun2009"
"13sep2008" "13jun2009"
"03jun2011" "17feb2012"
"03jun2011" "17feb2012"
"03jun2011" "17feb2012"
"04jan2016" "03oct2016"
"21dec2011" "26sep2012"
"21dec2011" "26sep2012"
"02jan2007" "18sep2007"
"02jan2007" "18sep2007"
"30sep2014" "30jun2015"
"06mar2014" "11dec2014"
"22aug2008" "29may2009"
"23dec2014" "22sep2015"
"27sep2014" "27jun2015"
"27sep2014" "27jun2015"
"30apr2010" "04feb2011"
"30apr2010" "04feb2011"
"30apr2010" "04feb2011"
"30apr2010" "04feb2011"
"30apr2010" "04feb2011"
"26nov2007" "08sep2008"
"15mar2015" "13dec2015"
"15mar2015" "13dec2015"
"02nov2013" "26jul2014"
"25nov2008" "08sep2009"
"12jul2009" "18apr2010"
"12jul2009" "18apr2010"
"12jul2009" "18apr2010"
"15dec2009" "14sep2010"
"15oct2011" "14jul2012"
"16may2012" "27feb2013"
"19jun2010" "19feb2011"
"19jun2010" "19feb2011"
"19jun2010" "19feb2011"
"19jun2010" "19feb2011"
"10dec2014" "02sep2015"
"10dec2014" "02sep2015"
"27jul2010" "19apr2011"
"17mar2016" "15dec2016"
"18aug2014" "18may2015"
"27jun2014" "27mar2015"
"29mar2013" "20dec2013"
"22dec2014" "07sep2015"
"22dec2014" "07sep2015"
"22dec2014" "07sep2015"
"24aug2008" "07jun2009"
"24aug2008" "07jun2009"
"24aug2008" "07jun2009"
"24aug2008" "07jun2009"
"09dec2014" "08sep2015"
"18aug2015" "10may2016"
"30jan2016" "22oct2016"
"30jan2016" "22oct2016"
"27mar2016" "25dec2016"
"10may2011" "07feb2012"
"27mar2014" "01jan2015"
"04sep2008" "18jun2009"
"04sep2008" "18jun2009"
"11nov2014" "28jul2015"
"20nov2015" "12aug2016"
"16oct2008" "16jul2009"
"16oct2008" "16jul2009"
"01may2011" "12feb2012"
"23mar2015" "21dec2015"
"30jun2008" "13apr2009"
"10sep2011" "16jun2012"
"16dec2010" "08sep2011"
"13oct2012" "13jul2013"
"13oct2012" "13jul2013"
"23apr2015" "21jan2016"
"27may2012" "24feb2013"
"17feb2009" "10nov2009"
"02sep2015" "01jun2016"
"21oct2014" "21jul2015"
"27apr2012" "08feb2013"
"27apr2012" "08feb2013"
"27apr2008" "01feb2009"
"06feb2015" "20nov2015"
"01aug2010" "17apr2011"
"13jun2007" "19mar2008"
"13jun2007" "19mar2008"
"13jun2007" "19mar2008"
end
Thanks for your help in advance!