BookmarkSubscribeRSS Feed
hema_bhure
Calcite | Level 5

Hi,
Thanks In advance

I need to calculate the end_date using start date.

The date columns is in date format.

I want to calculate the end_date on basis of id and term_month_begin and term_month_end.

Pease help me to get data correctly

input dataset
------------------------

id Term_month_begin Term_Month_end Start_dt
1 6 6 2011-01-04
1 12 12 2011-01-04
2 3 3 2011-01-04
2 3 3 2016-02-04
2 6 6 2017-02-03
2 6 6 2018-02-01

output I want
------------------
id Term_month_begin Term_Month_end Start_dt end_dt
1 6 6 2011-01-04 9999-99-99
1 12 12 2011-01-04 9999-99-99
2 3 3 2011-01-04 2016-02-03
2 3 3 2016-02-04 9999-99-99
2 6 6 2017-02-03 2017-12-31
2 6 6 2018-02-01 9999-99-99

3 REPLIES 3
Shmuel
Garnet | Level 18

1) A date like '9999-99-99' is not a valid date. You can either assign value as '9999-12-31' or keep a separate variable for indication (1 or 0);

 

2) It is not clear when the end_dt should be assigned as '9999-99-99' and when to skip to next following observation(s) or how and when to compute the end_dt. 

hema_bhure
Calcite | Level 5
hank you Shumuel, but i need to calculate other date apart from 9999-99-99. I have tried lag function but not getting proper output
PaigeMiller
Diamond | Level 26

But you haven't explained how to determine when you want 9999-99-99.

 

You also haven't explained how to compute END_DT when it is not 9999-99-99.

--
Paige Miller

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 3 replies
  • 436 views
  • 0 likes
  • 3 in conversation