Hello Everyone,
I am trying to find the difference in two dates in number of days. I have dates in numeric format as follows:
20150218 |
20150216 |
20150219 |
20150220 |
20150315 |
20150317 |
20150319 |
20150320 |
20150321 |
20150322 |
Now I want the difference of theses dates from 20161001 in number of days.
Thanks in advance !
SAS has better ways to store dates, instead of using an 8-digit number. If you used SAS's usual methods, you could just code:
difference = '01oct2016'd - mydate;
Given the data you already have, you will need a more complex formula:
difference = '01oct2016'd - input(put(mydate, 8.), yymmdd8.);
SAS has better ways to store dates, instead of using an 8-digit number. If you used SAS's usual methods, you could just code:
difference = '01oct2016'd - mydate;
Given the data you already have, you will need a more complex formula:
difference = '01oct2016'd - input(put(mydate, 8.), yymmdd8.);
How did you import the CSV?
That should be under your control and best practice would be to read it in as a date.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.