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;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.