BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mkd
Calcite | Level 5 mkd
Calcite | Level 5

I need help figuring out how to add this SQL code to SAS using proc sql.  I get the error messages that are listed below the code.

AND lh.CreateDate >= CAST(CONVERT(VARCHAR(8),GETDATE()-1,1) as DATETIME)

ERROR: Function VARCHAR could not be located.

ERROR: Function GETDATE could not be located.

ERROR: Expression using subtraction :smileyminus: requires numeric types.

ERROR: Function CONVERT could not be located.

ERROR: Function CAST could not be located.

ERROR: Expression using greater than or equal (>=) has components that are of different data

       types.

ERROR: The following columns were not found in the contributing tables: DATETIME.

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

What is the intent of the code. CAST() and GETDATE() are not functions available in SAS.

If you want to get today's date use the TODAY() or DATE() function.

If you want to get the current datetime then use the DATETIME() function.

Which you use will depend on what you want to do and whether the variable CreateDate contains dates or datetime values.

View solution in original post

4 REPLIES 4
SASKiwi
PROC Star

If CreateDate is a SAS Date something like this:

AND lh.CreateDate >= (today() - 1)

PravinMishra
Quartz | Level 8

Hi,

Cast is a teradata function.and If you want to use in porc sql. you can define while creating libname.

libname teradatalib teradata user=user_name pw=pwd cast=yes;

Thanks

Tom
Super User Tom
Super User

What is the intent of the code. CAST() and GETDATE() are not functions available in SAS.

If you want to get today's date use the TODAY() or DATE() function.

If you want to get the current datetime then use the DATETIME() function.

Which you use will depend on what you want to do and whether the variable CreateDate contains dates or datetime values.

mkd
Calcite | Level 5 mkd
Calcite | Level 5

Thanks, with your help I figured it out.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 4 replies
  • 9648 views
  • 5 likes
  • 4 in conversation