Date is formatted as such: 25JAN2018
and Time is formatted as such: 16:18:23
Trying to return a new field to where datetime is returned: 25JAN2018 16:18:23
I tried a cast function on both fields and attempted to combine and no such luck. Is there anyway to do this in PROC SQL?
Thanks in advance.
@PhatRam33 wrote:
It is in SQL pass-through. The date field is in date9 format I believe and the time field is in time8 format if that helps.
In that case you need to know which flavor of SQL your foreign database is using and find the appropriate command in that language. Are you using Oracle? Teradata? Redshift? Microsoft SQL Server? IBM ?? etc.
CAST() is not a SAS function, are you using SQL Pass through and are the fields SAS dates or character variables?
If it's SAS dates/times you can use the DHMS() function to compile the date and format as desired.
@PhatRam33 wrote:
Date is formatted as such: 25JAN2018
and Time is formatted as such: 16:18:23
Trying to return a new field to where datetime is returned: 25JAN2018 16:18:23
I tried a cast function on both fields and attempted to combine and no such luck. Is there anyway to do this in PROC SQL?
Thanks in advance.
It is in SQL pass-through. The date field is in date9 format I believe and the time field is in time8 format if that helps.
@PhatRam33 wrote:
It is in SQL pass-through. The date field is in date9 format I believe and the time field is in time8 format if that helps.
In that case you need to know which flavor of SQL your foreign database is using and find the appropriate command in that language. Are you using Oracle? Teradata? Redshift? Microsoft SQL Server? IBM ?? etc.
The language for the database is IBM DB2 I believe.
I figured it out. Once I found out the language of the database, the wheels started turning lol. Tom I give you credit though I totally missed this key question.
Was able to use the timestamp function with success:
timestamp(CREATE_DT, CREATE_TM) as CREATE_DT_TM
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.
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.