BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi I am a new SAS user and am having difficulty when running a query as part of the proc sql statement. The Error log reads that the following functions are NOT LOCATED.

TO_CHAR, ADD_MONTH,TRUNC,LAST_DAY,DECODE,NVL

I am an oracle PL/SQL Programmer and hence am trying to run that sql here. Do I have alternate function names that I should be using instead of the above?

Any help will be greatly appreciated. Thanks.
2 REPLIES 2
Olivier
Pyrite | Level 9
Hi Caesar.
The SAS Sql procedure uses a mixture of SQL standard syntax and SAS functions. Those listed in your message should be replaced by almost-equivalent SAS functions (check the SAS doc about them for the syntax, use, results, and so on).

TO_CHAR --> PUT

ADD_MONTH(thisDate, nbMonths) --> INTNX("MONTH", thisDate, nbMonths) + DAY(thisDate)-1
/* the INTNX("MONTH") function returns a date on the first day of the month */

TRUNC --> FLOOR / INT / ROUND (depending on what you want to do)

LAST_DAY --> INTNX("MONTH", date, 1) - 1

DECODE --> IFC / IFN (SAS 9 functions), CASE WHEN ELSE syntax

NVL(var1, var2) --> COALESCE(var1, var2)

Regards.
Olivier
deleted_user
Not applicable
Thanks Oliver... That was really helpful !

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 2 replies
  • 2007 views
  • 0 likes
  • 2 in conversation