BookmarkSubscribeRSS Feed
Sharan
Obsidian | Level 7

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

4 REPLIES 4
PeterClemmensen
Tourmaline | Level 20

How do you define end of trimester dates? In terms of days after Preg_Start? 

PGStats
Opal | Level 21

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.

PG
Ksharp
Super User
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;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

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!

Register Now

Creating Custom Steps in SAS Studio

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1786 views
  • 1 like
  • 5 in conversation