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.
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
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
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.