Desktop productivity for business analysts and programmers

alter session set nls_date_format='YYYYMMDD HH24:MI:SS'

Posts: 1

alter session set nls_date_format='YYYYMMDD HH24:MI:SS'

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:MISmiley FrustratedS' 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
Posts: 149

Re: alter session set nls_date_format='YYYYMMDD HH24:MI:SS'

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:MISmiley FrustratedS, 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.
Ask a Question
Discussion stats
  • 1 reply
  • 2 in conversation