## Displaying the lifetime of a deal (enddate-startdate) in a practical, intuitive way

Solved
Frequent Contributor
Posts: 100

# Displaying the lifetime of a deal (enddate-startdate) in a practical, intuitive way

Indulge for a moment in the charming fantasy that you have a table with two columns, called DealStartDate and DealEndDate. Both are in the DATE9 format, displayed as for example 29AUG2012 and 02SEP2012. A mysterious stranger asks you to create a new column called DealLifetime, which should display how long the deal lasted (basically DealEndDate-DealStartDate).

How would you choose to display DealLifetime? As a simple numeric variable displaying the number of days? Is there a practical way to display the years, months, days, etc., in a single field? The format should be intuitive.

Accepted Solutions
Solution
‎02-13-2013 10:25 AM
Posts: 1,147

## Re: Displaying the lifetime of a deal (enddate-startdate) in a practical, intuitive way

Hi,

Hope this is what you are expecting, just separated the day, month and year. please let me know if this is not what you are looking for..

data test;

input date1 : date9. date2 :date9.;

format date1 date2 date9.;

days_month_year=catx('-',put(intck('day',date1,date2),8.),put(intck('month',date1,date2),8.),put(intck('year',date1,date2),8.));

cards;

29AUG2012 02SEP2012

;

run;

days_

month_

Obs        date1         date2           year

1     29AUG2012    02SEP2012    4-1-0

Thanks,

Thanks,
Jag

All Replies
Solution
‎02-13-2013 10:25 AM
Posts: 1,147

## Re: Displaying the lifetime of a deal (enddate-startdate) in a practical, intuitive way

Hi,

Hope this is what you are expecting, just separated the day, month and year. please let me know if this is not what you are looking for..

data test;

input date1 : date9. date2 :date9.;

format date1 date2 date9.;

days_month_year=catx('-',put(intck('day',date1,date2),8.),put(intck('month',date1,date2),8.),put(intck('year',date1,date2),8.));

cards;

29AUG2012 02SEP2012

;

run;

days_

month_

Obs        date1         date2           year

1     29AUG2012    02SEP2012    4-1-0

Thanks,