BookmarkSubscribeRSS Feed
imdickson
Quartz | Level 8

Hi SAS Community.

 

This is what i am facing currently. I am having difficulty to convert SAS Datetime to SQL Datetime.

The display value in SAS Datetime is 28Mar2018:10:01:06 which is actually "28Mar2018:10:01:96"dt when doing Proc SQL.

The display value is SQL Datetime is 2018-03-28 10:01:06.000 which is actually '2018-03-28 10:01:06.000' when using SQL Pass through.

 

I have the SAS datetime value and want to use it in SQL Pass through statement. I have been finding online but i couldnt find any related information. The most i could find is only converting Date.

 

The Passthrough statement should be something like this(without the connect to xxx statement)

 

%let sasdatetime=2018-03-28 10:01:06.000;

/*How to convert the value above to SQL format and apply in proc sql below*/


Proc sql:

connect to xxx
select *

from table A

where birthdatetime = &thedatetime;

 

 

Seeking for your kind advice.

1 REPLY 1
ChrisNZ
Tourmaline | Level 20

Like this?

where birthdatetime = %nrbquote('&sasdatetime') ;

 

 

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 1464 views
  • 0 likes
  • 2 in conversation