I need to convert the SAS code below to SQL.
/* This an age calculation used to determine the members age on the First day of the report period. The calculation takes the difference in years between the DOB and date of service.
It then subtracts one if the month and day of the date of service is less than the month and day of the DOB.*/
(INTCK('YEAR', t1.MEME_DOB, t1.RPTPD_BEG_DT)-((put(MONTH(t1.RPTPD_BEG_DT),z2.)||put(DAY(t1.RPTPD_BEG_DT),z2.))< (put(MONTH(t1.MEME_DOB),z2.)||put(DAY(t1.MEME_DOB),z2.)))) AS RPTPD_BEG_AGE
I’ve tried a combo of DATEFROMPARTS and DATEADD, but am not quite there.
Optional_ is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
3