Help using Base SAS procedures

I need help with Proc SQL

Accepted Solution Solved
Reply
New Contributor mkd
New Contributor
Posts: 4
Accepted Solution

I need help with Proc SQL

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.


Accepted Solutions
Solution
‎10-21-2014 08:13 AM
Super User
Super User
Posts: 7,039

Re: I need help with Proc SQL

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


All Replies
Super User
Posts: 3,250

Re: I need help with Proc SQL

If CreateDate is a SAS Date something like this:

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

Contributor
Posts: 60

Re: I need help with Proc SQL

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

Solution
‎10-21-2014 08:13 AM
Super User
Super User
Posts: 7,039

Re: I need help with Proc SQL

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.

New Contributor mkd
New Contributor
Posts: 4

Re: I need help with Proc SQL

Thanks, with your help I figured it out.

🔒 This topic is solved and locked.

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

Discussion stats
  • 4 replies
  • 3360 views
  • 5 likes
  • 4 in conversation