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.
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.
If CreateDate is a SAS Date something like this:
AND lh.CreateDate >= (today() - 1)
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
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.
Thanks, with your help I figured it out.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.