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-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 2592 views
  • 0 likes
  • 2 in conversation