BookmarkSubscribeRSS Feed
itshere
Obsidian | Level 7

Hello - 

 

I currently have 2016-01-01 in my data.. its format is text,20. 

 

I want to join it with another table that i have and its format is 01JAN2016 00:00:00

 

How do I first convert the text DATE into number DATE and then in the correct format to join on this ^

 

I initially did Input(A.int_date, datetime20.) but it made all the rows blank. 

 

Any ideas?


Thanks!

3 REPLIES 3
PGStats
Opal | Level 21

Build a SAS datetime value with function DHMS

 

dt = dhms(input(A.int_date, yymmdd10.), 0, 0, 0);

format dt datetime20.;

PG
itshere
Obsidian | Level 7
I forgot to mention Im using PROC SQL

So i need something that is supported by that.
ballardw
Super User

dhms(input(A.int_date, yymmdd10.), 0, 0, 0) is supported by SAS Proc SQL.

You can us the value in a where clause as: Where dhms(input(A.int_date, yymmdd10.), 0, 0, 0) > <some datetime value>

or

join on dhms(input(A.int_date, yymmdd10.), 0, 0, 0) = b.datetimevariablename

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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
  • 3 replies
  • 898 views
  • 0 likes
  • 3 in conversation