BookmarkSubscribeRSS Feed
SASACC
Calcite | Level 5
Hi,

I copied a file from Oracle to SAS.
There is a date field in the data set which is a numeric field with format and informat 23.

I tried checking like '01OCT2009'D but this doest work.
Please let me know if there is any way to convert this field into sas date.
3 REPLIES 3
ArtC
Rhodochrosite | Level 12
The conversion should have been made for you if the Oracle date was identified as such and you used PROC IMPORT or the ORACLE engine.

I think that Oracle bases its dates on 1jan1900. It is possible therefore that your date is 60 years worth of days too big. if this is the case the correction is:

date = date+'01jan1900'd;
Peter_C
Rhodochrosite | Level 12
the proper solution depends on "how" you copied that data.
However, try a date-time format like datetime, or (if you expected only date information) DTDATE.

most of the database interfaces to SAS collect date information as a datetime value
Patrick
Opal | Level 21
Hi

Unlike SAS Oracle has a lot of different field types.

If the field type in Oracle is date or datetime then it should translate correctly to a SAS datetime format.

What I've seen already is that people store a date in a numeric field (as a number and not as a date), let's say 20100618.
If this is the case then SAS can't know that this field should be interpreted as a date but reads it simply as a number. If you want to convert such a field to a date or datetime then you have to either do this in SAS (with format, informat) or if you're using pass through SQL you can also convert the field already in Oracle using the appropriate formats there.

I believe to remember that in Oracle dates start from 1January1970.

HTH
Patrick

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