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

I'm using Proc SQL to query an oracle database.  I have a date that comes through as a datetime20.  When I convert it to a SAS data, the numeric value of that data is 10 digits long.  Given that the dates are all in the past few years, the numeric value should be around 18000 (ex 4/13/2009 minus 1/1/1960 is 18000).  How do I get the date from Oracle to accurately be reflected in SAS?  My code is at work (I'm at home now), but it generally looks like this:

PROC SQL;

     CREATE TABLE APPT AS

     (SELECT A.DATE FORMAT datew. FROM LIB.APPOINTMENT);

QUIT;

An example value in the field "Appointment" is 1080844400'.  Why is it 10 digits long?  The actual dates are recent, so should they all be around five digits?

Thanks in advance.

Tom

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

You have the date in datetime still, so its really in seconds I think. You can use the datepart function to get only the date.

select datepart(a.date) as date format date9. ...

View solution in original post

5 REPLIES 5
Reeza
Super User

You have the date in datetime still, so its really in seconds I think. You can use the datepart function to get only the date.

select datepart(a.date) as date format date9. ...

Tushar
Obsidian | Level 7

Or you can provide your own format irrespective whatever date format you are reading, like use anydtdte. informat

ex,

data want;

  input date anydtdte.;

  format date date9.;

  cards;

28MAY1927:00:00:00

;

run;

sugeshnambiar
Fluorite | Level 6

please provide date sample that appear in oracle...

jakarman
Barite | Level 11

Please review: SAS/ACCESS(R) 9.4 for Relational Databases: Reference, Second Edition (Data Types for Oracle)

Oracle is using datetime (char) as date fields. Conversions SAS to Oracel vice/versa must support this conversion. Give the needed addtional information to all procedures and steps including formats (SAS).


SAS is using datetime as equivalent being the number of seconds since 1 jan 1960.

DBTYPE and DBSASTYPE can help in overwrite automatic conversions 

---->-- ja karman --<-----
teg_76
Calcite | Level 5

Thank you all for your help!  I really appreciate it!  Nice and simple solution.  Thanks Reeza!

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 3442 views
  • 6 likes
  • 5 in conversation