SAS Enterprise Guide

Desktop productivity for business analysts and programmers
BookmarkSubscribeRSS Feed
Damon
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.

Thanks.
Damon
1 REPLY 1
RichardH_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: http://support.sas.com/kb/8/510.html. I believe the format you create would need to be applied separately to each column in reports you want values to display that way.

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 1 reply
  • 3334 views
  • 0 likes
  • 2 in conversation