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 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of 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
  • 2238 views
  • 0 likes
  • 2 in conversation