<?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: extracting the last digit from a numeric value in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/extracting-the-last-digit-from-a-numeric-value/m-p/595873#M171496</link>
    <description>&lt;P&gt;Is account a number (and if so why?) or a character string?&amp;nbsp; The subject line says number and the example data appears left justified like a character string.&amp;nbsp; Depending on which you have use one of these methods.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where mod(account,1000) = 999 ;
where substrn(account,length(account)-2)='999';
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 11 Oct 2019 20:14:07 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2019-10-11T20:14:07Z</dc:date>
    <item>
      <title>extracting the last digit from a numeric value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extracting-the-last-digit-from-a-numeric-value/m-p/595856#M171490</link>
      <description>&lt;P&gt;Hello, below is the dataset and I want to display only those obs. where last 3 digits in the amount&amp;nbsp; ends with 999.&lt;/P&gt;&lt;P&gt;thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;id&amp;nbsp; &amp;nbsp;amount&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; 678&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; 73999&lt;/P&gt;&lt;P&gt;3&amp;nbsp; &amp;nbsp; &amp;nbsp;6574&lt;/P&gt;&lt;P&gt;4&amp;nbsp; &amp;nbsp; 7699&lt;/P&gt;&lt;P&gt;5&amp;nbsp; &amp;nbsp; 672908&lt;/P&gt;&lt;P&gt;6&amp;nbsp; &amp;nbsp; 69999&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Oct 2019 19:41:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extracting-the-last-digit-from-a-numeric-value/m-p/595856#M171490</guid>
      <dc:creator>meetagupta</dc:creator>
      <dc:date>2019-10-11T19:41:11Z</dc:date>
    </item>
    <item>
      <title>Re: extracting the last digit from a numeric value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extracting-the-last-digit-from-a-numeric-value/m-p/595858#M171491</link>
      <description>Try the SUBSTRN() function - note the N.</description>
      <pubDate>Fri, 11 Oct 2019 19:51:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extracting-the-last-digit-from-a-numeric-value/m-p/595858#M171491</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-10-11T19:51:31Z</dc:date>
    </item>
    <item>
      <title>Re: extracting the last digit from a numeric value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extracting-the-last-digit-from-a-numeric-value/m-p/595870#M171495</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/288578"&gt;@meetagupta&lt;/a&gt;:&lt;/P&gt;
&lt;P&gt;The MOD function is your friend:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;                      
  input id amount ;              
  cards ;                        
1     678                        
2   73999                        
3    6574                        
4    7699                        
5  672908                        
6   69999                        
;                                
run ;                            
                                 
data want ;                      
  set have ;                     
  last_digit = mod (amount, 10) ;
run ;                            
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;Paul D.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Oct 2019 20:02:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extracting-the-last-digit-from-a-numeric-value/m-p/595870#M171495</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2019-10-11T20:02:31Z</dc:date>
    </item>
    <item>
      <title>Re: extracting the last digit from a numeric value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extracting-the-last-digit-from-a-numeric-value/m-p/595873#M171496</link>
      <description>&lt;P&gt;Is account a number (and if so why?) or a character string?&amp;nbsp; The subject line says number and the example data appears left justified like a character string.&amp;nbsp; Depending on which you have use one of these methods.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where mod(account,1000) = 999 ;
where substrn(account,length(account)-2)='999';
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Oct 2019 20:14:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extracting-the-last-digit-from-a-numeric-value/m-p/595873#M171496</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-10-11T20:14:07Z</dc:date>
    </item>
    <item>
      <title>Re: extracting the last digit from a numeric value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extracting-the-last-digit-from-a-numeric-value/m-p/595881#M171498</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;:&lt;/P&gt;
&lt;P&gt;It seems it says "amount" rather than "account". And it's my understanding that by "last digit", the OP means the least significant, i.e. rightmost digit.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the variable in question a digit string, methinks the simplest is:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  last_digit = char (amountC, length (amountC)) ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Plus, it's convenient that CHAR returns $1 suitable for a single digit character.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;Paul D.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Oct 2019 20:34:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extracting-the-last-digit-from-a-numeric-value/m-p/595881#M171498</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2019-10-11T20:34:27Z</dc:date>
    </item>
    <item>
      <title>Re: extracting the last digit from a numeric value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extracting-the-last-digit-from-a-numeric-value/m-p/595882#M171499</link>
      <description>&lt;P&gt;Not sure how the last digit can ever equal 999.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Oct 2019 20:35:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extracting-the-last-digit-from-a-numeric-value/m-p/595882#M171499</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-10-11T20:35:33Z</dc:date>
    </item>
    <item>
      <title>Re: extracting the last digit from a numeric value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extracting-the-last-digit-from-a-numeric-value/m-p/595884#M171500</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;: Me neither. A case where the title mismatches the content.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Oct 2019 20:38:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extracting-the-last-digit-from-a-numeric-value/m-p/595884#M171500</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2019-10-11T20:38:47Z</dc:date>
    </item>
    <item>
      <title>Re: extracting the last digit from a numeric value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extracting-the-last-digit-from-a-numeric-value/m-p/595925#M171516</link>
      <description>&lt;P&gt;Not the first subject content disagreement, even today:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would go with the&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;Hello, below is the dataset and I want to display only those obs. where &lt;STRONG&gt;last 3 digits&lt;/STRONG&gt; in the amount&amp;nbsp; ends with 999.&lt;/P&gt;
&lt;P&gt;thanks.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But would also be concerned about potential decimal portion of the value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Oct 2019 23:21:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extracting-the-last-digit-from-a-numeric-value/m-p/595925#M171516</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-10-11T23:21:19Z</dc:date>
    </item>
  </channel>
</rss>

