BookmarkSubscribeRSS Feed
Calcite | Level 5
HI There,

I'm new to SAS and I am having some problems with Dates, I need to do a comparative analysis on a relational Database, and in the past using other applications I could run the code alter session set nls_date_format='YYYYMMDD HH24:MI:SS' to allow the date to be formatted into the same format as the DB. I want to know how I can exectute that Oracle code using SAS.

SAS Employee
I don't know a huge amount about Oracle in particular, but here are some basic pointers:

1. Databases like Oracle usually store dates and times in their date fields. SAS has separate concepts for date values and datetime values. The translation of Oracle datetime information into SAS datetime information usually works without any problems; however, getting Oracle datetime information into SAS date information requires a little more finese. There's a SAS function, DATEPART, that extracts a SAS date value from a datetime value. To use other SAS date functions like MONTH, YEAR, INTNX, etc. you often want date information and thus need to use that DATEPART function. If you don't mind doing your analysis with datetime information only, you don't need to worry as much.

2. In terms of the displaying values as YYYYMMDD HH24:MI:SS, I didn't see a default SAS format for displaying things that way, so you might need to create a user-defined format to do the job. This would be an example of a picture format. Take a look at some examples here: I believe the format you create would need to be applied separately to each column in reports you want values to display that way.


Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.


Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 1 reply
  • 2 in conversation