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;

Ready to join fellow brilliant minds for the SAS Hackathon?

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!
SAS Enterprise Guide vs. SAS Studio

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 691 views
  • 0 likes
  • 5 in conversation