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;
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: