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

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.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

@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.

View solution in original post

5 REPLIES 5
Reeza
Super User

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.

 

 


 

PhatRam33
Fluorite | Level 6

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.

Tom
Super User Tom
Super User

@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.

PhatRam33
Fluorite | Level 6

The language for the database is IBM DB2 I believe.

PhatRam33
Fluorite | Level 6

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

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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