<?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: 16 Nachkommastellen anzeigen in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/16-Nachkommastellen-anzeigen/m-p/648893#M194471</link>
    <description>&lt;P&gt;Doing calculations in SAS 9.4 (not Viya) with numbers with 16 decimal places will not result in accurate calculations in the lower decimal places.&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;In one of my projects, we needed to create a sum of number in millions of rows that had 18 significant digits.&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;We therefore split we split the numbers into 2 parts and converted each part into 9 digit integers.&lt;/P&gt;
&lt;P&gt;At then end of the calculation, you need to calculate how much to carry-over from the less significant columns.&amp;nbsp; &amp;nbsp;(This is similar to how you add a long list of of numbers with pen and paper)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 19 May 2020 15:56:11 GMT</pubDate>
    <dc:creator>DavePrinsloo</dc:creator>
    <dc:date>2020-05-19T15:56:11Z</dc:date>
    <item>
      <title>16 Nachkommastellen anzeigen</title>
      <link>https://communities.sas.com/t5/SAS-Programming/16-Nachkommastellen-anzeigen/m-p/648794#M194424</link>
      <description>&lt;P&gt;Ich habe in meiner Datei 18 Zeichen eine Kommazahl davon immer 16 Nachkommastellen&amp;nbsp; z.b. &amp;nbsp;&lt;FONT&gt;0,1574167635461456&lt;/FONT&gt;&lt;/P&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT&gt;data test;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT&gt;a='0,1574167635461456';&lt;BR /&gt;b=input(a,commax18.16);&lt;BR /&gt;c=input(a,numx18.16);&lt;BR /&gt;format b commax25.16 c 32.29;&lt;BR /&gt;put a b c;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT&gt;run;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT&gt;Beim Umwandeln von char in num gehen 2 nachkommastellen verloren, auch wenn ich beim Input a numx18.16 angebe.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT&gt;b=0,1574167635461400&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;c&lt;FONT&gt;=0.15741676354614000000000000000&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT&gt;Ich benötige die Variable numerisch , um damit weiter zu rechnen.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT&gt;Was muss ich angeben, damit mir 16 Nachkommastellen erhalten bleiben?&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT&gt;Vielen Dank für Eure Hilfe&lt;/FONT&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 May 2020 10:41:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/16-Nachkommastellen-anzeigen/m-p/648794#M194424</guid>
      <dc:creator>SASStala1</dc:creator>
      <dc:date>2020-05-19T10:41:18Z</dc:date>
    </item>
    <item>
      <title>Re: 16 Nachkommastellen anzeigen</title>
      <link>https://communities.sas.com/t5/SAS-Programming/16-Nachkommastellen-anzeigen/m-p/648800#M194427</link>
      <description>&lt;P&gt;Zuallererst sollte man beim INPUT keine Nachkommastellen angeben, da man damit das Komma im String übersteuert. SAS entfernt das Komma, liest 18 Stellen, und dividiert durch 10**16.&lt;/P&gt;
&lt;P&gt;Weiters stösst man mit so vielen Stellen bereits an die Präzisionsgrenze des 8 Byte Floating Point Formats, in dem SAS Zahlen speichert; die 16. Nachkommastelle wird immer ungenau sein.&lt;/P&gt;</description>
      <pubDate>Tue, 19 May 2020 11:15:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/16-Nachkommastellen-anzeigen/m-p/648800#M194427</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-05-19T11:15:25Z</dc:date>
    </item>
    <item>
      <title>Re: 16 Nachkommastellen anzeigen</title>
      <link>https://communities.sas.com/t5/SAS-Programming/16-Nachkommastellen-anzeigen/m-p/648856#M194453</link>
      <description>&lt;P&gt;Hallo,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/329690"&gt;@SASStala1&lt;/a&gt;, und willkommen in den SAS Support Communities!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P data-unlink="true"&gt;Es scheint nur so, dass durch die Typumwandlung zwei Nachkommastellen "verloren" gehen. Die beobachtete Ungenauigkeit kommt im wesentlichen durch die gerundete Darstellung der allermeisten numerischen Formate zustande (auch wenn "ausreichend viele" Nachkommastellen im Format spezifiziert werden). Den exakten Wert, der in einer numerischen Variable gespeichert ist, erhält man am sichersten mit Formaten wie &lt;A href="https://documentation.sas.com/?docsetId=leforinforref&amp;amp;docsetTarget=n0ueabv26pr2fwn19uxk2f4bf10y.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank" rel="noopener"&gt;HEX16.&lt;/A&gt; oder &lt;A href="https://documentation.sas.com/?docsetId=leforinforref&amp;amp;docsetTarget=p1b6ugw71lmhnpn1wixijtysezzg.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank" rel="noopener"&gt;BINARY64.&lt;/A&gt;, freilich nicht in dezimaler Darstellung.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sofern die interne 64-Bit-Genauigkeit ausreicht, kann man mit einem benutzerdefinierten &lt;A href="https://documentation.sas.com/?docsetId=proc&amp;amp;docsetTarget=p0n990vq8gxca6n1vnsracr6jp2c.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank" rel="noopener"&gt;PICTURE-Format&lt;/A&gt; fehlende Dezimalstellen sichtbar machen, insgesamt aber höchstens 16. Im vorliegenden Beispiel ist das der Fall, denn intern (siehe HEX16.- oder BINARY64.-Darstellung) wird diese Zahl als eine Binärzahl gespeichert, die dezimal&amp;nbsp;0,157416763546145&lt;STRONG&gt;5&lt;/STRONG&gt;&lt;EM&gt;8830&lt;/EM&gt;... entspricht, d. h., der Rundungsfehler gegenüber der Zahl in der Character-Variablen beträgt in Wirklichkeit nur etwa 1.17E-17.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
picture longfmt
0&amp;lt;-&amp;lt;1='9.999999999999999E-l' (mult=1e16);
run;

proc print data=test;
format b longfmt.;
var b;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Ergebnis:&lt;/P&gt;
&lt;PRE&gt;Obs             b

 1     1.574167635461456E-l&lt;/PRE&gt;
&lt;P&gt;Die Dezimalstellen sind nun (mit Glück) alle sichtbar. Das der Beschränkung auf 16 Ziffernplatzhalter geschuldete kleine "L" in "&lt;FONT face="courier new,courier"&gt;E-l&lt;/FONT&gt;" ist allerdings unschön.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Falls die 16 Nachkommastellen unverfälscht in einem Bericht benötigt werden, würde ich eher die ursprüngliche Character-Variable verwenden und ggf. für Berechnungen eine zusätzliche numerische Variable anlegen (und die Rundungsfehler in diesem Grenzbereich der mit numerischen Variablen möglichen Genauigkeit im Auge behalten).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS: Es gibt hier mit CoDe SAS auch ein deutschsprachiges Unterforum:&amp;nbsp;&lt;A href="https://communities.sas.com/t5/CoDe-SAS-German/gp-p/code_sas" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/CoDe-SAS-German/gp-p/code_sas&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 19 May 2020 14:37:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/16-Nachkommastellen-anzeigen/m-p/648856#M194453</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2020-05-19T14:37:36Z</dc:date>
    </item>
    <item>
      <title>Re: 16 Nachkommastellen anzeigen</title>
      <link>https://communities.sas.com/t5/SAS-Programming/16-Nachkommastellen-anzeigen/m-p/648893#M194471</link>
      <description>&lt;P&gt;Doing calculations in SAS 9.4 (not Viya) with numbers with 16 decimal places will not result in accurate calculations in the lower decimal places.&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;In one of my projects, we needed to create a sum of number in millions of rows that had 18 significant digits.&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;We therefore split we split the numbers into 2 parts and converted each part into 9 digit integers.&lt;/P&gt;
&lt;P&gt;At then end of the calculation, you need to calculate how much to carry-over from the less significant columns.&amp;nbsp; &amp;nbsp;(This is similar to how you add a long list of of numbers with pen and paper)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 May 2020 15:56:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/16-Nachkommastellen-anzeigen/m-p/648893#M194471</guid>
      <dc:creator>DavePrinsloo</dc:creator>
      <dc:date>2020-05-19T15:56:11Z</dc:date>
    </item>
    <item>
      <title>Re: 16 Nachkommastellen anzeigen</title>
      <link>https://communities.sas.com/t5/SAS-Programming/16-Nachkommastellen-anzeigen/m-p/649096#M194564</link>
      <description>&lt;P&gt;Vielen Dank für die hilfreichen Antworten.&lt;/P&gt;</description>
      <pubDate>Wed, 20 May 2020 06:20:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/16-Nachkommastellen-anzeigen/m-p/649096#M194564</guid>
      <dc:creator>SASStala1</dc:creator>
      <dc:date>2020-05-20T06:20:47Z</dc:date>
    </item>
  </channel>
</rss>

