<?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 Format sizekmg. from KB to bytes not always working in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Format-sizekmg-from-KB-to-bytes-not-always-working/m-p/770217#M244342</link>
    <description>&lt;P&gt;&lt;SPAN&gt;I would like to convert file sizes from MB, KB to Bytes. This can of course also be done via a formula, only I have used the format sizekmg. . Now I get for certain cases that it does not work, like with size_kb_2. Does anyone know why this is not working properly?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;SAS Code:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;data test;&lt;BR /&gt;size_kb_1="32.04KB";&lt;BR /&gt;size_kb_2="159.61KB";&lt;/P&gt;&lt;P&gt;size_bytes_1 = input(size_kb_1,sizekmg.);&lt;BR /&gt;size_bytes_2= input(size_kb_2,sizekmg.);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Output dataset test:&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Stephanvd_0-1632488371929.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/64034i2D106E6FF4133CF3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Stephanvd_0-1632488371929.png" alt="Stephanvd_0-1632488371929.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 24 Sep 2021 13:02:44 GMT</pubDate>
    <dc:creator>Stephanvd</dc:creator>
    <dc:date>2021-09-24T13:02:44Z</dc:date>
    <item>
      <title>Format sizekmg. from KB to bytes not always working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-sizekmg-from-KB-to-bytes-not-always-working/m-p/770217#M244342</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I would like to convert file sizes from MB, KB to Bytes. This can of course also be done via a formula, only I have used the format sizekmg. . Now I get for certain cases that it does not work, like with size_kb_2. Does anyone know why this is not working properly?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;SAS Code:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;data test;&lt;BR /&gt;size_kb_1="32.04KB";&lt;BR /&gt;size_kb_2="159.61KB";&lt;/P&gt;&lt;P&gt;size_bytes_1 = input(size_kb_1,sizekmg.);&lt;BR /&gt;size_bytes_2= input(size_kb_2,sizekmg.);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Output dataset test:&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Stephanvd_0-1632488371929.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/64034i2D106E6FF4133CF3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Stephanvd_0-1632488371929.png" alt="Stephanvd_0-1632488371929.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Sep 2021 13:02:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-sizekmg-from-KB-to-bytes-not-always-working/m-p/770217#M244342</guid>
      <dc:creator>Stephanvd</dc:creator>
      <dc:date>2021-09-24T13:02:44Z</dc:date>
    </item>
    <item>
      <title>Re: Format sizekmg. from KB to bytes not always working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-sizekmg-from-KB-to-bytes-not-always-working/m-p/770223#M244344</link>
      <description>data test;&lt;BR /&gt;size_kb_1="32.04KB";&lt;BR /&gt;size_kb_2="159.61KB";&lt;BR /&gt;&lt;BR /&gt;size_bytes_1 = input(size_kb_1,sizekmg12.2);&lt;BR /&gt;size_bytes_2= input(size_kb_2,sizekmg12.2);&lt;BR /&gt;run;</description>
      <pubDate>Fri, 24 Sep 2021 13:06:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-sizekmg-from-KB-to-bytes-not-always-working/m-p/770223#M244344</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-09-24T13:06:17Z</dc:date>
    </item>
    <item>
      <title>Re: Format sizekmg. from KB to bytes not always working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-sizekmg-from-KB-to-bytes-not-always-working/m-p/770230#M244348</link>
      <description>&lt;P&gt;Like the SIZEKMG format, the informat has a default width of 6, and therefore misses part of the string when you omit to specify a width.&lt;/P&gt;
&lt;P&gt;So this works:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
size_kb_1="32.04KB";
size_kb_2="159.61KB";
size_bytes_1 = input(size_kb_1,sizekmg12.);
size_bytes_2= input(size_kb_2,sizekmg12.);
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note: do not use a fractional part in the informat unless you absolutely need it (when there's no dot in the input string, but the last x digits have to be considered as decimal fractions). A string of 1234, read with 6.2, would result in a number of 12.34.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Sep 2021 13:21:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-sizekmg-from-KB-to-bytes-not-always-working/m-p/770230#M244348</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-09-24T13:21:18Z</dc:date>
    </item>
    <item>
      <title>Re: Format sizekmg. from KB to bytes not always working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-sizekmg-from-KB-to-bytes-not-always-working/m-p/770232#M244350</link>
      <description>&lt;P&gt;Note that including the number of decimal places in an INFORMAT is telling SAS to divide any strings without an explicit decimal point by that power of ten.&amp;nbsp; &amp;nbsp;Unless you know that the strings have expressly removed the decimal point to save one byte do not include the number of decimal places in the INFORMAT.&amp;nbsp; Just specify the total width.&amp;nbsp; And since INPUT() does not care if the informat width is larger than the length of the string it is reading you can just use the maximum allowed width.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;sizekmg35.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Sep 2021 13:20:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-sizekmg-from-KB-to-bytes-not-always-working/m-p/770232#M244350</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-09-24T13:20:34Z</dc:date>
    </item>
    <item>
      <title>Re: Format sizekmg. from KB to bytes not always working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-sizekmg-from-KB-to-bytes-not-always-working/m-p/770233#M244351</link>
      <description>Ha. Follow the Kurt's comment .&lt;BR /&gt;For the safety ,using "sizekmg12." ,NOT "sizekmg12.2" .</description>
      <pubDate>Fri, 24 Sep 2021 13:21:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-sizekmg-from-KB-to-bytes-not-always-working/m-p/770233#M244351</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-09-24T13:21:01Z</dc:date>
    </item>
  </channel>
</rss>

