- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 07-01-2021 06:19 PM
(2067 views)
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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)
Proc SQL;
select b.this, a.this,
case
When b.rate <0.25 Then coalesce(somenum/b.rate,0)