Hi all,
In one table I have a date field called "DATE" that shows up as 20160401. It is type numeric formatted YYMMDDn8.
In my second table I have a date field called "DATE2" that shows up as 20545 (a SAS date) which is type numeric with no format.
I'm trying to join these tables together by customer name (in both tables) and the date fields but I am struggling to convert the dates into similar format before the join. Is there an easy way to convert the YYMMDDn8. and convert it to a SAS date? Perhaps that idea is making this more complicated?
From your description no conversion is needed, both variable have the number of days since 1960. The reason the values look different to you is just because they are being displayed using different formats. YYMMDD vs BEST.
From your description no conversion is needed, both variable have the number of days since 1960. The reason the values look different to you is just because they are being displayed using different formats. YYMMDD vs BEST.
Tom,
So I should be ignoring what fields visually looked like when they are dates and SAS will take care of it? Pardon the ignorance here.
Hi,
Yes, in your example that is true. The format on the DATE variable just changes the appearance of the variable when output, it's still stored as a numeric (number of days from 1 Jan 1960).
Here's a simple example that might help:
data _null_ ;
date=today() ;
date2=today() ;
format date date7. ;
put "date: " date "date2: " date2;
if date=date2 then
put "date = date2 even if they appear different" ;
run ;
https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/... has a PDF with much information about dates.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.