BookmarkSubscribeRSS Feed
Calcite | Level 5
Hello everyone
Can u help me in finding difference between the dates
I have attached the file
Diamond | Level 26

Some of us (like me) will not download attached files, so I can't see your data. Please include the data in your reply as plain text, following these examples and instructions.


Also, please be specific and explain what you want as output, provide an example of the "difference" or "differences" you want to see.



Paige Miller
Super User

Your code in the attachment shows "date" as character values. So you really need to define what you mean by difference.


If the values are actual SAS date values then you can get all sorts of intervals from different date values. If the values were actual SAS date values then you could use the DIF function to get number of days since the previous record.


@Divyanshu870 wrote:
Hello everyone
Can u help me in finding difference between the dates
I have attached the file


Super User Tom
Super User

Why do to the trouble to make a photograph of text, store it in a PDF file and then upload the file?


Just copy and past the text into the forum editor.  Use the Insert SAS Code icon to get a pop-up window to paste/edit the code so its formatting is retained.


Your example program is not reading in dates.  It is instead making a character variable named DATE.  To make a numeric variable use the DDMMYY informat.  Then attach a format to the numeric variable so it prints in a way that humans will understand. Avoid using DDMMYY or MMDDYY format as either one will confuse half of your audience.  Use the DATE format or the YYMMDD format instead and avoid the confusion.


Once you have date values then you can just subtract them to find the difference in days between the two dates.



Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg



Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 4 in conversation