BookmarkSubscribeRSS Feed
GN0001
Barite | Level 11

Hello team,

Proc SQL;
select b.this, a.this, 
case
When b.rate <0.25 Then (somenum/b.rate)

b.rate is equal 0, then we have divide by zero. This produces errors in Excel and is handled by IfError.

What is the equal of IFError is in SAS?

respectfully,

Blue blue

Blue Blue
3 REPLIES 3
PaigeMiller
Diamond | Level 26
case when b.rate>0 and b.rate <0.25 then (somenum/b.rate)

This will not produce an error in SAS, but the resulting variable is still missing in SAS.

 

You can also do this:

 

case when b.rate <0.25 then divide(somenum,b.rate)

which also gives a missing, but no error.

--
Paige Miller
KatScott
Fluorite | Level 6

The following will replicate the same behavior as IFERROR.

Proc SQL;
select b.this, a.this, 
case
When b.rate <0.25 Then coalesce(somenum/b.rate.0) 

For more information please see:

Function documentation:


https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/sqlproc/p1gdr5t7sd3g3qn1d7fg23zuwzml.htm#!


An example:
https://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a002473712.htm

 

Best,

K

KatScott
Fluorite | Level 6
One correction I needed a comma:

Proc SQL;
select b.this, a.this,
case
When b.rate <0.25 Then coalesce(somenum/b.rate,0)

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
  • 3 replies
  • 2592 views
  • 3 likes
  • 3 in conversation