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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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