<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Format magic in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Format-magic/m-p/2451#M1045</link>
    <description>Hi, Olivier:&lt;BR /&gt;
  No answers. Just more questions. The same thing happens when you use a format OUTSIDE of the PUT statement as shown below. Interestingly enough, when I take the subtraction out of the mix, then the format works as expected.&lt;BR /&gt;
cynthia&lt;BR /&gt;
*** another example;[pre]&lt;BR /&gt;
data test;&lt;BR /&gt;
try=1;&lt;BR /&gt;
x = 3.4-2.8;&lt;BR /&gt;
y = 2.9-2.6;&lt;BR /&gt;
pcta = (y-x)/x*100;&lt;BR /&gt;
output;&lt;BR /&gt;
          &lt;BR /&gt;
try=2;&lt;BR /&gt;
x = 3.4000-2.8000;&lt;BR /&gt;
y = 2.9000 - 2.6000;&lt;BR /&gt;
pcta = (y-x)/x*100;&lt;BR /&gt;
output;&lt;BR /&gt;
          &lt;BR /&gt;
try=3;&lt;BR /&gt;
x = 3.4000-2.8000;&lt;BR /&gt;
y = 2.9000 - 2.6000;&lt;BR /&gt;
pcta = (y-x)/x*100.00;&lt;BR /&gt;
output;&lt;BR /&gt;
             &lt;BR /&gt;
try=4;&lt;BR /&gt;
x = .60000000;&lt;BR /&gt;
y = .30000000;&lt;BR /&gt;
pcta = (y-x)/x*100;&lt;BR /&gt;
output;&lt;BR /&gt;
           &lt;BR /&gt;
try=5;&lt;BR /&gt;
x = .488888;&lt;BR /&gt;
y = .244444;&lt;BR /&gt;
pcta = (y-x)/x*100;&lt;BR /&gt;
output;&lt;BR /&gt;
             &lt;BR /&gt;
try=6;&lt;BR /&gt;
x = .5;&lt;BR /&gt;
y = .25;&lt;BR /&gt;
pcta = (y-x)/x*100;&lt;BR /&gt;
output;&lt;BR /&gt;
           &lt;BR /&gt;
try=7;&lt;BR /&gt;
x = .750000;&lt;BR /&gt;
y = .350000;&lt;BR /&gt;
pcta = (y-x)/x*100;&lt;BR /&gt;
output;&lt;BR /&gt;
            &lt;BR /&gt;
try=8;&lt;BR /&gt;
x = .75000;&lt;BR /&gt;
y = .37500;&lt;BR /&gt;
pcta = (y-x)/x*100;&lt;BR /&gt;
output;&lt;BR /&gt;
           &lt;BR /&gt;
try=9;&lt;BR /&gt;
x = .75000;&lt;BR /&gt;
y = .37499;&lt;BR /&gt;
pcta = (y-x)/x*100;&lt;BR /&gt;
output;&lt;BR /&gt;
            &lt;BR /&gt;
try=10;&lt;BR /&gt;
x = .75000;&lt;BR /&gt;
y = .37511;&lt;BR /&gt;
pcta = (y-x)/x*100;&lt;BR /&gt;
output;&lt;BR /&gt;
run; &lt;BR /&gt;
           &lt;BR /&gt;
proc report data=test nowd;&lt;BR /&gt;
column try x y pcta pcta=two pcta=three;&lt;BR /&gt;
define pcta / display 'Unformatted pcta' width=12;&lt;BR /&gt;
define two / display format=pcta. 'with pcta fmt' width=5;&lt;BR /&gt;
define three / display format=pctb. 'with pctb fmt' width=5;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]</description>
    <pubDate>Fri, 09 Mar 2007 15:28:45 GMT</pubDate>
    <dc:creator>Cynthia_sas</dc:creator>
    <dc:date>2007-03-09T15:28:45Z</dc:date>
    <item>
      <title>Format magic</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Format-magic/m-p/2450#M1044</link>
      <description>Hello all.&lt;BR /&gt;
I'm a long-time friend of formats, and I was puzzled when this strange thing appened to one of my clients. I can't figure any explanation to this ; maybe one of you would have an idea ?&lt;BR /&gt;
Question is sent to Tech Support in France, but no answer yet.&lt;BR /&gt;
&lt;BR /&gt;
The thing is : &lt;BR /&gt;
1) I create to different formats, which only differ in an extra interval for one of them ;&lt;BR /&gt;
2) I compute a value which is approximately -50 (due to roundings, the true value is not exactly -50 but I don't think this is really the point, or at least not the ONLY problem)&lt;BR /&gt;
3) I use these two formats on the same value, and in spite of the same definition of intervals for value -50 in both formats, I end up with two DIFFERENT values !&lt;BR /&gt;
&lt;BR /&gt;
Amazing, isn't it ?&lt;BR /&gt;
&lt;BR /&gt;
Here is my sample program :&lt;BR /&gt;
&lt;BR /&gt;
proc format ;&lt;BR /&gt;
value pcta  -80-&amp;lt;-50 = "A     "                                                                                                    &lt;BR /&gt;
             -50-&amp;lt;-10 = "B     "  &lt;BR /&gt;
			 -10-high= "X     " &lt;BR /&gt;
             ;          &lt;BR /&gt;
value pctb   -80-&amp;lt;-50 = "A     "                                                                                                    &lt;BR /&gt;
             -50-&amp;lt;-10 = "B     " &lt;BR /&gt;
             ; &lt;BR /&gt;
run;  &lt;BR /&gt;
data test;&lt;BR /&gt;
 x       = 3.4-2.8;&lt;BR /&gt;
 y       = 2.9-2.6;&lt;BR /&gt;
 pcta = (y-x)/x*100;&lt;BR /&gt;
run; &lt;BR /&gt;
proc sql ;&lt;BR /&gt;
	select PUT(pctA,pcta.), PUT(pctA,pctb.)&lt;BR /&gt;
	from test&lt;BR /&gt;
	;&lt;BR /&gt;
quit ;&lt;BR /&gt;
&lt;BR /&gt;
Any ideas welcome !&lt;BR /&gt;
Regards&lt;BR /&gt;
Olivier</description>
      <pubDate>Fri, 09 Mar 2007 08:22:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Format-magic/m-p/2450#M1044</guid>
      <dc:creator>Olivier</dc:creator>
      <dc:date>2007-03-09T08:22:39Z</dc:date>
    </item>
    <item>
      <title>Re: Format magic</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Format-magic/m-p/2451#M1045</link>
      <description>Hi, Olivier:&lt;BR /&gt;
  No answers. Just more questions. The same thing happens when you use a format OUTSIDE of the PUT statement as shown below. Interestingly enough, when I take the subtraction out of the mix, then the format works as expected.&lt;BR /&gt;
cynthia&lt;BR /&gt;
*** another example;[pre]&lt;BR /&gt;
data test;&lt;BR /&gt;
try=1;&lt;BR /&gt;
x = 3.4-2.8;&lt;BR /&gt;
y = 2.9-2.6;&lt;BR /&gt;
pcta = (y-x)/x*100;&lt;BR /&gt;
output;&lt;BR /&gt;
          &lt;BR /&gt;
try=2;&lt;BR /&gt;
x = 3.4000-2.8000;&lt;BR /&gt;
y = 2.9000 - 2.6000;&lt;BR /&gt;
pcta = (y-x)/x*100;&lt;BR /&gt;
output;&lt;BR /&gt;
          &lt;BR /&gt;
try=3;&lt;BR /&gt;
x = 3.4000-2.8000;&lt;BR /&gt;
y = 2.9000 - 2.6000;&lt;BR /&gt;
pcta = (y-x)/x*100.00;&lt;BR /&gt;
output;&lt;BR /&gt;
             &lt;BR /&gt;
try=4;&lt;BR /&gt;
x = .60000000;&lt;BR /&gt;
y = .30000000;&lt;BR /&gt;
pcta = (y-x)/x*100;&lt;BR /&gt;
output;&lt;BR /&gt;
           &lt;BR /&gt;
try=5;&lt;BR /&gt;
x = .488888;&lt;BR /&gt;
y = .244444;&lt;BR /&gt;
pcta = (y-x)/x*100;&lt;BR /&gt;
output;&lt;BR /&gt;
             &lt;BR /&gt;
try=6;&lt;BR /&gt;
x = .5;&lt;BR /&gt;
y = .25;&lt;BR /&gt;
pcta = (y-x)/x*100;&lt;BR /&gt;
output;&lt;BR /&gt;
           &lt;BR /&gt;
try=7;&lt;BR /&gt;
x = .750000;&lt;BR /&gt;
y = .350000;&lt;BR /&gt;
pcta = (y-x)/x*100;&lt;BR /&gt;
output;&lt;BR /&gt;
            &lt;BR /&gt;
try=8;&lt;BR /&gt;
x = .75000;&lt;BR /&gt;
y = .37500;&lt;BR /&gt;
pcta = (y-x)/x*100;&lt;BR /&gt;
output;&lt;BR /&gt;
           &lt;BR /&gt;
try=9;&lt;BR /&gt;
x = .75000;&lt;BR /&gt;
y = .37499;&lt;BR /&gt;
pcta = (y-x)/x*100;&lt;BR /&gt;
output;&lt;BR /&gt;
            &lt;BR /&gt;
try=10;&lt;BR /&gt;
x = .75000;&lt;BR /&gt;
y = .37511;&lt;BR /&gt;
pcta = (y-x)/x*100;&lt;BR /&gt;
output;&lt;BR /&gt;
run; &lt;BR /&gt;
           &lt;BR /&gt;
proc report data=test nowd;&lt;BR /&gt;
column try x y pcta pcta=two pcta=three;&lt;BR /&gt;
define pcta / display 'Unformatted pcta' width=12;&lt;BR /&gt;
define two / display format=pcta. 'with pcta fmt' width=5;&lt;BR /&gt;
define three / display format=pctb. 'with pctb fmt' width=5;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Fri, 09 Mar 2007 15:28:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Format-magic/m-p/2451#M1045</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2007-03-09T15:28:45Z</dc:date>
    </item>
    <item>
      <title>Re: Format magic</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Format-magic/m-p/2452#M1046</link>
      <description>Cynthia, I'm glad that it is not a silly question and that it can also puzzle the SAS people. Anyway, you managed to add a Report procedure in the problem, this sounds like you're report-addicted !!! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
&lt;BR /&gt;
Anyway, something weirder, since it doesn't seem to be related in any way, yet solves the problem :&lt;BR /&gt;
&lt;BR /&gt;
proc format ;&lt;BR /&gt;
value pcta (NOTSORTED)&lt;BR /&gt;
-80-&amp;lt;-50 = "A " &lt;BR /&gt;
-50-&amp;lt;-10 = "B " &lt;BR /&gt;
-10-high= "X " &lt;BR /&gt;
; &lt;BR /&gt;
value pctb -80-&amp;lt;-50 = "A " &lt;BR /&gt;
-50-&amp;lt;-10 = "B " &lt;BR /&gt;
; &lt;BR /&gt;
run; &lt;BR /&gt;
&lt;BR /&gt;
Adding the NOTSORTED option makes both formats work the same way. But it doesn't sound more logical to me anyway.&lt;BR /&gt;
&lt;BR /&gt;
I already solved the problem adding a FUZZ option to the format. What I want is to understand what's happening here, and how adding intervals can disturb the way a formats handle the same value !&lt;BR /&gt;
&lt;BR /&gt;
Have a nice weekend (time to flee from work, here in France) !&lt;BR /&gt;
Olivier</description>
      <pubDate>Fri, 09 Mar 2007 16:07:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Format-magic/m-p/2452#M1046</guid>
      <dc:creator>Olivier</dc:creator>
      <dc:date>2007-03-09T16:07:14Z</dc:date>
    </item>
  </channel>
</rss>

