<?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 w.d format was too small in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/w-d-format-was-too-small/m-p/734684#M228856</link>
    <description>&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i want to eliminate w.d note from these calculations&lt;/P&gt;&lt;P&gt;data test1;&lt;BR /&gt;calc=77;&lt;BR /&gt;call symputx('calc',calc);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data test;&lt;BR /&gt;input numb;&lt;BR /&gt;datalines;&lt;BR /&gt;77&lt;BR /&gt;58&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;data test2;&lt;BR /&gt;set test;&lt;BR /&gt;total=numb/&amp;amp;calc*100;&lt;BR /&gt;total2=PUT (total,4.1);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i've tried to round total&lt;/P&gt;&lt;P&gt;data test2;&lt;BR /&gt;set test;&lt;BR /&gt;total=round(numb/&amp;amp;calc*100,4.1);&lt;BR /&gt;total2=PUT (total,4.1);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and it doesnt print me w.d but... i have wrong results, sas shows me that&amp;nbsp;(77/77*100,4.1)=98.4 instead of 100. I don't understand this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you for your help&lt;/P&gt;</description>
    <pubDate>Fri, 16 Apr 2021 09:58:52 GMT</pubDate>
    <dc:creator>Jedrzej</dc:creator>
    <dc:date>2021-04-16T09:58:52Z</dc:date>
    <item>
      <title>w.d format was too small</title>
      <link>https://communities.sas.com/t5/SAS-Programming/w-d-format-was-too-small/m-p/734684#M228856</link>
      <description>&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i want to eliminate w.d note from these calculations&lt;/P&gt;&lt;P&gt;data test1;&lt;BR /&gt;calc=77;&lt;BR /&gt;call symputx('calc',calc);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data test;&lt;BR /&gt;input numb;&lt;BR /&gt;datalines;&lt;BR /&gt;77&lt;BR /&gt;58&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;data test2;&lt;BR /&gt;set test;&lt;BR /&gt;total=numb/&amp;amp;calc*100;&lt;BR /&gt;total2=PUT (total,4.1);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i've tried to round total&lt;/P&gt;&lt;P&gt;data test2;&lt;BR /&gt;set test;&lt;BR /&gt;total=round(numb/&amp;amp;calc*100,4.1);&lt;BR /&gt;total2=PUT (total,4.1);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and it doesnt print me w.d but... i have wrong results, sas shows me that&amp;nbsp;(77/77*100,4.1)=98.4 instead of 100. I don't understand this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you for your help&lt;/P&gt;</description>
      <pubDate>Fri, 16 Apr 2021 09:58:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/w-d-format-was-too-small/m-p/734684#M228856</guid>
      <dc:creator>Jedrzej</dc:creator>
      <dc:date>2021-04-16T09:58:52Z</dc:date>
    </item>
    <item>
      <title>Re: w.d format was too small</title>
      <link>https://communities.sas.com/t5/SAS-Programming/w-d-format-was-too-small/m-p/734690#M228859</link>
      <description>&lt;P&gt;Here you are.&lt;/P&gt;
&lt;P&gt;By the way, do not use a macro variable to merge a single number to all records in another dataset.&lt;/P&gt;
&lt;P&gt;Use the "if _N_=1 then set" technique instead.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test1; calc=77; run;

data test;
 input numb;
 datalines;
77
58
;
run;

data test2;
 if _N_=1 then set test1;
 set test;
 total=numb/calc;
 put total= percent15.5;
 put total= percent10.0;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Fri, 16 Apr 2021 10:31:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/w-d-format-was-too-small/m-p/734690#M228859</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2021-04-16T10:31:18Z</dc:date>
    </item>
    <item>
      <title>Re: w.d format was too small</title>
      <link>https://communities.sas.com/t5/SAS-Programming/w-d-format-was-too-small/m-p/734691#M228860</link>
      <description>&lt;P&gt;Define total2 as char type with appropriate length:&lt;/P&gt;
&lt;P&gt;For format 4.2 assign LENGTH TOTAL2 $7;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Apr 2021 10:32:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/w-d-format-was-too-small/m-p/734691#M228860</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2021-04-16T10:32:10Z</dc:date>
    </item>
    <item>
      <title>Re: w.d format was too small</title>
      <link>https://communities.sas.com/t5/SAS-Programming/w-d-format-was-too-small/m-p/734693#M228861</link>
      <description>you mean this ?&lt;BR /&gt;data test2;&lt;BR /&gt;length total2 $7;&lt;BR /&gt;set test;&lt;BR /&gt;total=numb/&amp;amp;calc*100;&lt;BR /&gt;total2=PUT (total,4.2);&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;doesn't work, still w.d is too small in log...</description>
      <pubDate>Fri, 16 Apr 2021 10:47:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/w-d-format-was-too-small/m-p/734693#M228861</guid>
      <dc:creator>Jedrzej</dc:creator>
      <dc:date>2021-04-16T10:47:54Z</dc:date>
    </item>
    <item>
      <title>Re: w.d format was too small</title>
      <link>https://communities.sas.com/t5/SAS-Programming/w-d-format-was-too-small/m-p/734694#M228862</link>
      <description>hmm that doesn;t solve this problem</description>
      <pubDate>Fri, 16 Apr 2021 10:48:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/w-d-format-was-too-small/m-p/734694#M228862</guid>
      <dc:creator>Jedrzej</dc:creator>
      <dc:date>2021-04-16T10:48:22Z</dc:date>
    </item>
    <item>
      <title>Re: w.d format was too small</title>
      <link>https://communities.sas.com/t5/SAS-Programming/w-d-format-was-too-small/m-p/734695#M228863</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/107827"&gt;@Jedrzej&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just to add the explanations:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;The width &lt;EM&gt;w&lt;/EM&gt; of the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/leforinforref/n1n7bmvs1brl23n1dj9cbzau39df.htm" target="_blank" rel="noopener"&gt;&lt;EM&gt;w.d&lt;/EM&gt; format&lt;/A&gt; is the total&amp;nbsp;width of the output field, including the decimal point and the minus sign, if any. So, format &lt;FONT face="courier new,courier"&gt;4.1&lt;/FONT&gt; is sufficient for &lt;FONT face="courier new,courier"&gt;99.9&lt;/FONT&gt;, but for &lt;FONT face="courier new,courier"&gt;100.0&lt;/FONT&gt; you need &lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;5&lt;/STRONG&gt;.1&lt;/FONT&gt; (and for &lt;FONT face="courier new,courier"&gt;-100.0&lt;/FONT&gt; even &lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;6&lt;/STRONG&gt;.1&lt;/FONT&gt;).&lt;/LI&gt;
&lt;LI&gt;The second argument of the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/p0tj6cmga7p8qln1ejh6ebevm0c9.htm" target="_blank" rel="noopener"&gt;ROUND function&lt;/A&gt; is the rounding unit. In your case &lt;FONT face="courier new,courier"&gt;0.1&lt;/FONT&gt; would be a typical value (although not helpful for the &lt;EM&gt;w.d&lt;/EM&gt; format issue), whereas the very unusual&amp;nbsp;&lt;FONT face="courier new,courier"&gt;4.1&lt;/FONT&gt; rounds &lt;FONT face="courier new,courier"&gt;100 (=&lt;STRONG&gt;24&lt;/STRONG&gt;.39024...*4.1)&lt;/FONT&gt;&amp;nbsp;down to &lt;FONT face="courier new,courier"&gt;98.4 (=&lt;STRONG&gt;24&lt;/STRONG&gt;*4.1)&lt;/FONT&gt;.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Apr 2021 10:50:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/w-d-format-was-too-small/m-p/734695#M228863</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-04-16T10:50:55Z</dc:date>
    </item>
    <item>
      <title>Re: w.d format was too small</title>
      <link>https://communities.sas.com/t5/SAS-Programming/w-d-format-was-too-small/m-p/734696#M228864</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;total=round(numb/&amp;amp;calc*100,4.1);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;rounds to the nearest multiple of 4.1. The nearest multiple of 4.1 to 100 (100 is the value of &lt;FONT face="courier new,courier"&gt;numb/&amp;amp;calc*100&lt;/FONT&gt;) is 24*4.1=98.4&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to round to the nearest decimal place i.e. nearest tenth, you would want &lt;FONT face="courier new,courier"&gt;round(numb/&amp;amp;calc*100,0.1)&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Apr 2021 10:53:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/w-d-format-was-too-small/m-p/734696#M228864</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-04-16T10:53:10Z</dc:date>
    </item>
  </channel>
</rss>

