<?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: counting significant digits in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/counting-significant-digits/m-p/90615#M19190</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As already mentioned, there is a difference between significant digits (as in the title of your question) and the number of decimal places (as in the body of your question). My thoughts on this are that you need to know something about the data in order to determine how many significant digits should be used, regardless of how many decimals have been entered. However, if you do actually want to count decimal places and the field is numeric, I would query the entire dataset and take the maximum decimal places seen across all related records.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 28 Mar 2013 18:44:42 GMT</pubDate>
    <dc:creator>hey_tc</dc:creator>
    <dc:date>2013-03-28T18:44:42Z</dc:date>
    <item>
      <title>counting significant digits</title>
      <link>https://communities.sas.com/t5/SAS-Programming/counting-significant-digits/m-p/90609#M19184</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;here is a fun project.&amp;nbsp; I can think of many brute force approaches but I'm wondering if there is a better way.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to be able to count how many decimal places have been entered into into a field&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So if they enter 1.234 I need the output to say 3 and if it is 1.0 I need the output to say 1&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Mar 2013 18:51:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/counting-significant-digits/m-p/90609#M19184</guid>
      <dc:creator>wkossack_nspirehealth_com</dc:creator>
      <dc:date>2013-03-27T18:51:55Z</dc:date>
    </item>
    <item>
      <title>Re: counting significant digits</title>
      <link>https://communities.sas.com/t5/SAS-Programming/counting-significant-digits/m-p/90610#M19185</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not sure what you are really after, but if the variable is char, it is easy; if it is number, then you need to make some decision and convert it to char, but it is still not that hard:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/*if char*/&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input var $20.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; call scan (var,-1,p,length);&lt;/P&gt;&lt;P&gt;&amp;nbsp; cards;&lt;/P&gt;&lt;P&gt;1.234&lt;/P&gt;&lt;P&gt;1.0&lt;/P&gt;&lt;P&gt;25.65&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Length is supposed the ONE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Mar 2013 19:08:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/counting-significant-digits/m-p/90610#M19185</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2013-03-27T19:08:24Z</dc:date>
    </item>
    <item>
      <title>Re: counting significant digits</title>
      <link>https://communities.sas.com/t5/SAS-Programming/counting-significant-digits/m-p/90611#M19186</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What about integers?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;DIV style="font-family: Courier New; font-size: 11pt;"&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;16&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GOPTIONS ACCESSIBLE;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;17&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; data _null_;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;18&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; input var &lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;$20.&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;19&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call scan (var,-&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;1&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;,p,length);&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;20&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; d = findC(var,&lt;/SPAN&gt;&lt;SPAN style="color: #800080; background-color: #ffffff;"&gt;'.'&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #800080; background-color: #ffffff;"&gt;'T'&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;,-length(var));&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;21&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if d&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;22&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; then dec=length(var)-d;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;23&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else dec=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;0&lt;/STRONG&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;24&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; put (_all_) (=);&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;25&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cards;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;var=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;1.234&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; p=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;3&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; length=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;3&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; d=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;2&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; dec=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;3&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;var=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;1.0&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; p=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;3&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; length=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;1&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; d=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;2&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; dec=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;1&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;var=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;25.65&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; p=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;4&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; length=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;2&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; d=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;3&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; dec=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;2&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;var=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;156&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; p=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;1&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; length=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;3&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; d=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;0&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; dec=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;0&lt;/STRONG&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Mar 2013 20:18:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/counting-significant-digits/m-p/90611#M19186</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2013-03-27T20:18:29Z</dc:date>
    </item>
    <item>
      <title>Re: counting significant digits</title>
      <link>https://communities.sas.com/t5/SAS-Programming/counting-significant-digits/m-p/90612#M19187</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi DN,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Guess I am not a very good student. &lt;img id="smileywink" class="emoticon emoticon-smileywink" src="https://communities.sas.com/i/smilies/16x16_smiley-wink.png" alt="Smiley Wink" title="Smiley Wink" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Mar 2013 20:35:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/counting-significant-digits/m-p/90612#M19187</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2013-03-27T20:35:37Z</dc:date>
    </item>
    <item>
      <title>Re: counting significant digits</title>
      <link>https://communities.sas.com/t5/SAS-Programming/counting-significant-digits/m-p/90613#M19188</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If I remember my number theory correctly, that's not the technical definition of significant digits which has to do with numeric precision.&amp;nbsp; There are rules around how to count them.&amp;nbsp; For example, 0.000052 has two significant digits while 0.520000 has 6.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but...I may not be remember the theory correctly...and it may be more information than you actually need.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Mar 2013 21:02:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/counting-significant-digits/m-p/90613#M19188</guid>
      <dc:creator>DBailey</dc:creator>
      <dc:date>2013-03-27T21:02:05Z</dc:date>
    </item>
    <item>
      <title>Re: counting significant digits</title>
      <link>https://communities.sas.com/t5/SAS-Programming/counting-significant-digits/m-p/90614#M19189</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I vote with you. Given that trailing zeroes can be significant, and that because of decimal/hexadecimal conversion issues single decimal digits may blow out to multiple digits in internal representation, I suspect there's no real way to do this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tom&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Mar 2013 18:22:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/counting-significant-digits/m-p/90614#M19189</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2013-03-28T18:22:59Z</dc:date>
    </item>
    <item>
      <title>Re: counting significant digits</title>
      <link>https://communities.sas.com/t5/SAS-Programming/counting-significant-digits/m-p/90615#M19190</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As already mentioned, there is a difference between significant digits (as in the title of your question) and the number of decimal places (as in the body of your question). My thoughts on this are that you need to know something about the data in order to determine how many significant digits should be used, regardless of how many decimals have been entered. However, if you do actually want to count decimal places and the field is numeric, I would query the entire dataset and take the maximum decimal places seen across all related records.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Mar 2013 18:44:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/counting-significant-digits/m-p/90615#M19190</guid>
      <dc:creator>hey_tc</dc:creator>
      <dc:date>2013-03-28T18:44:42Z</dc:date>
    </item>
    <item>
      <title>Re: counting significant digits</title>
      <link>https://communities.sas.com/t5/SAS-Programming/counting-significant-digits/m-p/327969#M73213</link>
      <description>&lt;P&gt;If you want to count the number of significant digits, you need to combine the information of the precision (how many digits does the number have) and the order of magnitude (how large is the number).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You may use the formula: &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;significant_digits = lengthn(scan(number,2,'.')) + floor(log10(input(number,best.))) + 1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Or in code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data sign_digits;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;input number $20.;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;precision = lengthn(scan(number,2,'.'));&lt;BR /&gt;&amp;nbsp; &amp;nbsp;magnitude = floor(log10(input(number,best.)))+1;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;significant_digits = lengthn(scan(number,2,'.')) + floor(log10(input(number,best.))) + 1;&lt;BR /&gt;cards;&lt;BR /&gt;1.234&lt;BR /&gt;1.0&lt;BR /&gt;25.65&lt;BR /&gt;14&lt;BR /&gt;0.00002400&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Jan 2017 10:30:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/counting-significant-digits/m-p/327969#M73213</guid>
      <dc:creator>jeppesj</dc:creator>
      <dc:date>2017-01-27T10:30:39Z</dc:date>
    </item>
    <item>
      <title>Re: counting significant digits</title>
      <link>https://communities.sas.com/t5/SAS-Programming/counting-significant-digits/m-p/327974#M73216</link>
      <description>&lt;P&gt;This should suffice.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sample;
	input Values;
	datalines;
9.999
3.1245
919.0001
123.9999999
10
;
run;

data sample;
	set sample;
	cc=(scan(Values,2,"."));

	if cc="" then
		count=0;
	else count=length(cc);
	drop cc;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;-Hope it Helps.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Jan 2017 10:45:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/counting-significant-digits/m-p/327974#M73216</guid>
      <dc:creator>ankit___gupta</dc:creator>
      <dc:date>2017-01-27T10:45:33Z</dc:date>
    </item>
  </channel>
</rss>

