Solved

Comparing a sas calculated date to a date in a table

Posted on 2013-06-06
1
521 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
1 Comment
 
LVL 14

Accepted Solution

by:
Aloysius Low earned 500 total points
Comment Utility
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

In today’s complex data management environments, it is not unusual for UNIX servers to be dedicated to a particular department, purpose, or database.  As a result, a SAS® data analyst often works with multiple servers, each with its own data storage…
This article describes some very basic things about SQL Server filegroups.
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

744 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now