- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 05-28-2011 07:47 AM
(3690 views)
A colleague had a proc summary where a total count of positive and negative counts was zero on the data sheet in EG. The data manually pointed to a net result of zero. The total became a denominator in a percentage calculation and the business rule was to use the usual formula when the total was positive, a flag value when negative and a different flag value when it was zero. She used a SELECT and the negative flag value was produced instead of the zero flag value. We expanded the when (value < 0) statement out and putlog in each case printed zero using n=. The variable summed positive and negative whole numbers so floating point shouldn't have been a problem but tried k=fuzz(n) an putting y= and still got zero. Did an x=put(n, E12.) and putlog x= gave a left adjusted '0'. All this was in the do;...end; following the test on being less than zero.
I recall seeing reference to -0 being produced by proc summary and being displayed as '0' but taken to be less than plain vanilla 0 in SAS. I can't help wondering if this is such a case.
I recall seeing reference to -0 being produced by proc summary and being displayed as '0' but taken to be less than plain vanilla 0 in SAS. I can't help wondering if this is such a case.
4 REPLIES 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi
If this is a precision problem of some kind use a round() function before doing the comparison, i.e. round(value,0.00001)<0.
I've seen such cases with data coming from DB2 and the issue was caused by the way data is stored in DB2 compared to SAS.
HTH
Patrick
If this is a precision problem of some kind use a round() function before doing the comparison, i.e. round(value,0.00001)<0.
I've seen such cases with data coming from DB2 and the issue was caused by the way data is stored in DB2 compared to SAS.
HTH
Patrick
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Patrick. It was the sum of integer counts so there shouldn't be any floating point issues. I'll check the manual for a hex format that may reveal the bit pattern and compare with the pattern for zero. Applying the ROUND or FUZZ function may also by forcing it to be zero, help or even adding 1 and comparing with 1 then subtracting the 1. We were scratching our heads till near 7:30pm Friday night before we thought it could wait till Monday 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
data _null_;
value=0;
/* value=1/(10**200);*/
put "BEST32. for value " value best32. /;
if value=0 then put "Hex for value = 0 : " value hex16.;
else put "HEX for value ^= 0 : " value hex16.;
run;
HTH
Patrick
value=0;
/* value=1/(10**200);*/
put "BEST32. for value " value best32. /;
if value=0 then put "Hex for value = 0 : " value hex16.;
else put "HEX for value ^= 0 : " value hex16.;
run;
HTH
Patrick
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Problem solved. My colleague had set "options missing=0" and the value was missing rather than negative zero. I suggested she only use it in future just before ODS and then immediately issue "options missing=". again. A very dangerous option IMO. Seeing a '.' tells me I have my merges/joins wrong and that is important.