BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
srussell
Calcite | Level 5

I have two data sets.... one contains Billing Information and the other contains payments / adjustments.  The output of a join for the two sets has created a set of records where there have been no payments or adjustments causing the two fields (Cash and Adjustments) be flagged as Missing (.) on those records.

 

In order to calcluate Total AR as well as the current Invoice Balance, I need the Missing (.) to show as zero (0).

 

I've read several posts on this topic and thought I had a solution, however I'm getting a mixed bag of results with my variations:

 

IFN(t1.'Cash Applied'n > 0 or t1.'Cash Applied'n < 0, t1.'Cash Applied'n, 0, 0) -  Populates accurate original data (both positive and negative) when it was NOT missing but does NOT convert missing (.) to zero (0).

 

IFN(t1.'Cash Applied'n > 0, t1.'Cash Applied'n, 0, 0) - Populates original data (only if positive - negatives are lost) AND successfully converts missing (.) to zero (0).

 

IFN(t1.'Cash Applied'n < 0, t1.'Cash Applied'n, 0, 0) - Populates original data (only if negative - positives are lost) but does NOT convert missing (.) to zero (0).

 

I've even tried pulling negatives out and adding them back after a successful positive conversion, but it then reverts the value back to missing.  Essentially, the missing (.) to zero (0) conversion works great for positive numbers, and fails anytime I try to handle the negative values.

 

Any feedback you guys can provide would be greatly appreciated.

 

SAS EG 7.1 (64 bit)

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Is there some reason you don't want to use the MISSING function to test for a missing value?

 

When you compare . < 0 the result is true so your t1.'Cash Applied'n > 0 or t1.'Cash Applied'n < 0 will resolve to true when the variable value is missing, not missing for the comparison.

 

A case statement using when missing(t1.'Cash Applied'n) might be a better approach.

View solution in original post

3 REPLIES 3
ChrisHemedinger
Community Manager

Did you look at the tips in this post: How to set all missing values to zero?

 

PROC STDIZE might be the easiest thing, using REPONLY and MISSING=0.

SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!
ballardw
Super User

Is there some reason you don't want to use the MISSING function to test for a missing value?

 

When you compare . < 0 the result is true so your t1.'Cash Applied'n > 0 or t1.'Cash Applied'n < 0 will resolve to true when the variable value is missing, not missing for the comparison.

 

A case statement using when missing(t1.'Cash Applied'n) might be a better approach.

srussell
Calcite | Level 5

Your mention of the Missing function got me to thinking more along those lines and I was able to use it to identify those records with missing data and then update to zero based on that result.  Gave me the result I needed.

 

Thanks for your help.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 9108 views
  • 0 likes
  • 3 in conversation