BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
deega
Quartz | Level 8

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 !

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

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.);

View solution in original post

3 REPLIES 3
Astounding
PROC Star

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.);

deega
Quartz | Level 8
Thanks.... The input was not in my hand.. it is CSV file, i received...
Reeza
Super User

How did you import the CSV?

That should be under your control and best practice would be to read it in as a date. 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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