BookmarkSubscribeRSS Feed
nbonda
Obsidian | Level 7


I have a date vaiable extracted from SQL server (in SQL datatype is datetime2(7)), sas reading it as $27. example data value: (2015-06-09 14:20:00.0000000).

what is this data type called. how can I convert to numeric datetime20.?  appreciate you help.

2 REPLIES 2
data_null__
Jade | Level 19
data _null_;
  
do d = '2015-06-09 14:20:00.0000000';
      dt = input(d,
is8601dt26.);
      put d= dt=datetime22.2;
     
end;
  
run;

23         data _null_;
24            do d = '2015-06-09 14:20:00.0000000';
25               dt = input(d,is8601dt26.);
26               put d= dt=datetime22.2;
27               end;
28            run;

d=
2015-06-09 14:20:00.0000000 dt=09JUN2015:14:20:00.00
SASKiwi
PROC Star

How are you reading your data from SQL Server? If you are using ODBC, we found that using the latest version of the SQL Server ODBC driver translated datetimes correctly as datetimes not character:

40080 - SQL Server 2008 dates are read in as character when using SAS/ACCESS® Interface to ODBC

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