Solved

Comparing a sas calculated date to a date in a table

Posted on 2013-06-06
1
539 Views
Last Modified: 2013-06-06
Experts,

I have a column in a table with a datea  stored as 05/01/2013
                                                                                     06/01/2013   etc.

I would like to compare the calculated date:

Dateb = date() - weekday(date()) + 1;   which is SAS format 19511

Is there a way to compare these two dates?
0
Comment
Question by:morinia
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 14

Accepted Solution

by:
Aloysius Low earned 500 total points
ID: 39227630
Dates in SAS is stored as a number field but can be formatted to be displayed in almost any possible combination e.g. MM/DD/YYYY, DD/MM/YYYY etc so even if it's showing as a nice looking human readable date, what's underlying is still a number offset from 01 Jan 1960..

therefore:
if DateA is already a date field, you can compare directly i.e. if DateA = DateB then

if DateA is not already a date field but a character field, you can use the input function to convert the character date to it's numerical equivalent i.e. input(DateA, MMDDYY10.) assuming the date string is in MM/DD/YYYY format, or input(DateA, DDMMYY10.) if the date string is in DD/MM/YYYY format before comparing to DateB as above
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
Your data is at risk. Probably more today that at any other time in history. There are simply more people with more access to the Web with bad intentions.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question