Desktop productivity for business analysts and programmers

Replace Missing (.) values with "0" using EG Project

Accepted Solution Solved
Reply
New Contributor
Posts: 4
Accepted Solution

Replace Missing (.) values with "0" using EG Project

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)


Accepted Solutions
Solution
‎11-04-2016 04:29 PM
Super User
Posts: 11,139

Re: Replace Missing (.) values with "0" using EG Project

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


All Replies
Community Manager
Posts: 2,889

Re: Replace Missing (.) values with "0" using EG Project

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.

Solution
‎11-04-2016 04:29 PM
Super User
Posts: 11,139

Re: Replace Missing (.) values with "0" using EG Project

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.

New Contributor
Posts: 4

Re: Replace Missing (.) values with "0" using EG Project

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.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 384 views
  • 0 likes
  • 3 in conversation