Building models with SAS Enterprise Miner, SAS Factory Miner, SAS Visual Data Mining and Machine Learning or just with programming

Problem managing date in SAS

Accepted Solution Solved
Reply
Contributor
Posts: 58
Accepted Solution

Problem managing date in SAS

Hi,

I've the following problem managing date in SAS.

Here you are my code

proc sql;

   create table mycalendar as

    select distinct (datref - mynumber)   as mydatrf format = datetime20.

     from Library1.mydataset

;

quit;

Library1 points to a table on Oracle database where the field datref is a date and mynumber is numeric field.

My goal is to have the result of the query as "datetime20." SAS format but if I use the proc above it fails, because for example it the datref is 29/11/2011 and mynumber is -1 I get

29NOV2011:00:00:01 instead of 30NOV2011:00:00:00.

Any idea?

Many thanks


Accepted Solutions
Solution
‎12-13-2011 10:17 AM
PROC Star
Posts: 7,364

Problem managing date in SAS

Try it with:

proc sql;

   create table mycalendar as

    select distinct (datref - mynumber*24*60*60)   as mydatrf format = datetime20.

     from Library1.mydataset

;

quit;

View solution in original post


All Replies
Solution
‎12-13-2011 10:17 AM
PROC Star
Posts: 7,364

Problem managing date in SAS

Try it with:

proc sql;

   create table mycalendar as

    select distinct (datref - mynumber*24*60*60)   as mydatrf format = datetime20.

     from Library1.mydataset

;

quit;

Contributor
Posts: 58

Problem managing date in SAS

Thanks it works.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 188 views
  • 0 likes
  • 2 in conversation