SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
DavidPhillips2
Rhodochrosite | Level 12

What is the SAS proc sql equivalent of the oracle function is null that accepts two parameters the column you are checking and the value to use when null.  I found a reference to ifnull() function but when I tried it I got an error.  Maybe it's a simple syntax thing.

1 ACCEPTED SOLUTION

Accepted Solutions
mklangley
Lapis Lazuli | Level 10

COALESCE() for numeric variables.   (e.g. coalesce(numeric_var, 0) )

COALESCEC() for character variables.   (e.g. coalescec(char_var, 'abc') )

View solution in original post

2 REPLIES 2
mklangley
Lapis Lazuli | Level 10

COALESCE() for numeric variables.   (e.g. coalesce(numeric_var, 0) )

COALESCEC() for character variables.   (e.g. coalescec(char_var, 'abc') )

ballardw
Super User

IFNULL in SAS as far as I know is restricted to FEDSQL use and not for Proc SQL.

 

The Coalesce functions as @mklangley references will return the left most non-missing value of a list of variables or values (3,4,5 or more) so may be more flexible.

Coalescec (var1, var2,var3,'result') would 'result' if all of var1 through 3 were missing (or null for those who haven't quite mastered the SAS jargon yet).

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

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
  • 10802 views
  • 1 like
  • 3 in conversation