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

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?

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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.

View solution in original post

4 REPLIES 4
Tom
Super User Tom
Super User

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.

anweinbe
Quartz | Level 8

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. 

AMSAS
SAS Super FREQ

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 ;

 

SAS Innovate 2025: Register Now

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!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 780 views
  • 0 likes
  • 4 in conversation