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
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.
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
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.