BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I've got an ETL job that I want to be able to attach to multiple databases. One database has dates stored as DATETIME's and the other only as DATE's.

Is it possible to use one set of steps to convert these all to consistant SAS dates?
3 REPLIES 3
Olivier
Pyrite | Level 9
You should consider using this little program... (In a Code window.)

%LET dsIn = ... ; /* your existing DATETIME dataset*/
%LET dsOut = ... ; /* your converted dataset ; you can use the same name twice, and you will have your existing dataset replaced */
/*************************************************/
/* DO NOT EDIT ANYTHING AFTER THIS LINE */
/*************************************************/
PROC CONTENTS DATA = &dsIn (KEEP = _numeric_)
OUT = work.dictionary
NOPRINT ;
RUN ;
PROC SQL NOPRINT ;
SELECT name INTO : varToConvert SEPARATED BY " "
FROM work.dictionary
;
QUIT ;
DATA &dsOut ;
SET &dsIn ;
ARRAY datetimes &varToConvert ;
DO OVER dateTimes ;
dateTimes = DATEPART(dateTimes) ;
END ;
FORMAT &varToConvert DDMMYY10. ;
RUN ;
SPR
Quartz | Level 8 SPR
Quartz | Level 8
I noticed that the DATEPART function applied to a variable having date format (without time part) produces completely wrong results. So it is necessary to be sure that DATEPART is always applied to date-time variables.
Olivier
Pyrite | Level 9
The last remark is true. I should have added a WHERE statement in the SQL procedure. Something like :

WHERE UPCASE(format) = "DATETIME"

should focus conversion on DateTime variables only.
Message was edited by: Olivier at Sep 29, 2006 9:08 AM

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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