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 ;

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

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

View all other training opportunities.

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