DATA Step, Macro, Functions and more

datapart function works half the time

Reply
Occasional Contributor
Posts: 19

datapart function works half the time

I am having a problem with date conversion.  Sor some reason when I pull information from my datawarehouse using the datapart function in SQL the number ends up with a character format.  When I use the same procedure on a different table that has the date formatted the same way, the variable comes down as a numeric.  I checked the tables to make sure they are formatted the same way, and they are exactly the same.  In the meantime I just pulled the data using SQL in step one, and formatted the data in a "data step" in step two and that works.  But I am wordering if this is a common problem.  I had been running this job for over 2 years and had no problems.  I have enclosed an attachment that details my results.  SAS enterprise guide 6.1 64-bit

Super User
Posts: 17,963

Re: datapart function works half the time

This is a question for tech support.

Respected Advisor
Posts: 3,777

Re: datapart function works half the time

Respected Advisor
Posts: 3,777

Re: datapart function works half the time

@pangea17 I see you "liked" my post.  Does that mean it help you solve the problem and if so could you show the code you changed or whatever you did.  It would help to know if/how you fixed it.  It may be useful to others.

Occasional Contributor
Posts: 19

Re: datapart function works half the time

It didn't work as of yet, but my IT department is looking into the problem.

Respected Advisor
Posts: 3,777

Re: datapart function works half the time

Did you try the option?

 

A problem will result if later code treats that variable as a DATE rather than as a DATETIME. 
The only workaround is to turn off implicit pass-through so that the function is not passed
to the DBMS and is instead processed by SAS. This can be done by setting the DIRECT_EXE= LIBNAME option.
Super User
Posts: 3,115

Re: datapart function works half the time

What database and which SAS/ACCESS product are you using? 

Ask a Question
Discussion stats
  • 6 replies
  • 390 views
  • 2 likes
  • 4 in conversation