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 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!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 5 replies
  • 3896 views
  • 6 likes
  • 5 in conversation