SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

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

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 89
Accepted Solution

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.

Thanks for your time. Smiley Happy


Accepted Solutions
Solution
‎02-13-2013 10:25 AM
Trusted Advisor
Posts: 1,131

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,

Jagadish

Thanks,
Jag

View solution in original post


All Replies
Solution
‎02-13-2013 10:25 AM
Trusted Advisor
Posts: 1,131

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,

Jagadish

Thanks,
Jag
☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 1 reply
  • 153 views
  • 0 likes
  • 2 in conversation