Hi fellow SAS users,
I seek your help. I have a date variable which is pregnancy start date as preg_start. I would like to create 3 date vars: End of trimester 1, end of trimester 2 and end of trimester 3
I.e. I would like to calculate date at the end of each trimester.
Suppose my date is 1st jan 2005, I would like to have the output as follows:
Preg_start end_trimester_1 end_trimester_2 end_trimester3
1JAN2005 31Mar2005 30JUN2005 30SEP2005
How do you define end of trimester dates? In terms of days after Preg_Start?
A pregnancy trimester is defined as 13 weeks or 91 days, so you simply add the number 91 three times (SAS dates are counts of days).
If this is more than an exercise, I suggest that you refine your definition of "pregnancy start date" and "end of first/second/third trimester". A good place to start is the Wikipedia page on human Pregnancy.
data _null_; x='01jan2005'd; d1=intnx('qtr',x,1,'s')-1; d2=intnx('qtr',x,2,'s')-1; d3=intnx('qtr',x,3,'s')-1; put (x d:) (= date9.); run;
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.