<?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: Modulus-10 in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Modulus-10/m-p/243824#M6394</link>
    <description>Swell, the last digit to check is the ninth. The difference between the nearest larger multiple of ten should correspond to the tenth digit. So with a slight adjustment of the number of i, you function worked, which I show by using the common personal identity number with repeated 12 and by adding a flag for the result being correct or not. Thanks.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;data _null_;&lt;BR /&gt;x = '1212121212';&lt;BR /&gt;sum = 0;&lt;BR /&gt;do i = 1 to 9;&lt;BR /&gt;sumi = input(substr(x,i,1),1.);&lt;BR /&gt;if mod(i,2) = 1&lt;BR /&gt;then do;&lt;BR /&gt;sumi = sumi * 2;&lt;BR /&gt;if sumi &amp;gt; 9 then sumi = sumi - 9;&lt;BR /&gt;end;&lt;BR /&gt;sum + sumi;&lt;BR /&gt;put i=;&lt;BR /&gt;put sumi=;&lt;BR /&gt;end;&lt;BR /&gt;put sum=;&lt;BR /&gt;check = mod(sum,10);&lt;BR /&gt;put check=;&lt;BR /&gt;&lt;BR /&gt;if (int(check/10)+1)*10-check=substr(x,10,1) then do;&lt;BR /&gt;correct=1;&lt;BR /&gt;end;&lt;BR /&gt;else do;&lt;BR /&gt;correct=0;&lt;BR /&gt;end;&lt;BR /&gt;put correct=;&lt;BR /&gt;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Fri, 15 Jan 2016 16:18:31 GMT</pubDate>
    <dc:creator>Uppiskalle</dc:creator>
    <dc:date>2016-01-15T16:18:31Z</dc:date>
    <item>
      <title>Modulus-10</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Modulus-10/m-p/243765#M6386</link>
      <description>&lt;P&gt;Hi, I need to check Swedish personal identity numbers and need code to check wether the numer in a variable is correct or not. Please submit code if you have any.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jan 2016 13:24:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Modulus-10/m-p/243765#M6386</guid>
      <dc:creator>Uppiskalle</dc:creator>
      <dc:date>2016-01-15T13:24:03Z</dc:date>
    </item>
    <item>
      <title>Re: Modulus-10</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Modulus-10/m-p/243768#M6387</link>
      <description>&lt;P&gt;What is the exact condition for the number to be valid?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In reference to your thread title, you might take a look at the mod() function (if this is somehow used to verify that the number is a valid one)&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jan 2016 13:31:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Modulus-10/m-p/243768#M6387</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-01-15T13:31:20Z</dc:date>
    </item>
    <item>
      <title>Re: Modulus-10</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Modulus-10/m-p/243770#M6388</link>
      <description>The personal identity numer has 10 digits (YYYYMMDDXXXX) where the last digit is the checksum. Each of the first nine digits are multiplied, the first by 2, the second by 1, the third by 2, the fourth by 1 etc. Any sum bigger of 10 or bigger is handled as two numbers. The numbers are then summarized, and compared to the last checkshum using modulus-10 (giving the distance to the closest multiple of 10).&lt;BR /&gt;&lt;BR /&gt;Example 19630810-1632 makes 1*2+9*1+6*2+3*1+0*2+8*1+1*2+0*1+1*2+6*1+3*2=2+9+12+3+0+8+2+0+2+6 but the 12 is taken as 1+2 so that 2+9+1+2+3+0+8+2+0+2+6=35. This should be compared to the modulo 10 of 35 should correspond to the tenth digit in the personal identity number.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 15 Jan 2016 13:42:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Modulus-10/m-p/243770#M6388</guid>
      <dc:creator>Uppiskalle</dc:creator>
      <dc:date>2016-01-15T13:42:31Z</dc:date>
    </item>
    <item>
      <title>Re: Modulus-10</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Modulus-10/m-p/243779#M6389</link>
      <description>&lt;P&gt;The modulo of 35 by 10 would be 5. Where in the number should the 5 be found? Or should 5 then be the sum of the digits of the last 2 positions?&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jan 2016 14:22:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Modulus-10/m-p/243779#M6389</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-01-15T14:22:54Z</dc:date>
    </item>
    <item>
      <title>Re: Modulus-10</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Modulus-10/m-p/243783#M6390</link>
      <description>&lt;P&gt;A preliminary implementation of the check algorithm looks like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
x = '196308101632';
sum = 0;
do i = 1 to 10;
  sumi = input(substr(x,i,1),1.);
  if mod(i,2) = 1
  then do;
    sumi = sumi * 2;
    if sumi &amp;gt; 10 then sumi = sumi - 9;
  end;
  sum + sumi;
  put i=;
  put sumi=;
end;
put sum=;
check = mod(sum,10);
put check=;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The question is now, with what should we compare the value "check"?&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jan 2016 14:27:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Modulus-10/m-p/243783#M6390</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-01-15T14:27:38Z</dc:date>
    </item>
    <item>
      <title>Re: Modulus-10</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Modulus-10/m-p/243824#M6394</link>
      <description>Swell, the last digit to check is the ninth. The difference between the nearest larger multiple of ten should correspond to the tenth digit. So with a slight adjustment of the number of i, you function worked, which I show by using the common personal identity number with repeated 12 and by adding a flag for the result being correct or not. Thanks.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;data _null_;&lt;BR /&gt;x = '1212121212';&lt;BR /&gt;sum = 0;&lt;BR /&gt;do i = 1 to 9;&lt;BR /&gt;sumi = input(substr(x,i,1),1.);&lt;BR /&gt;if mod(i,2) = 1&lt;BR /&gt;then do;&lt;BR /&gt;sumi = sumi * 2;&lt;BR /&gt;if sumi &amp;gt; 9 then sumi = sumi - 9;&lt;BR /&gt;end;&lt;BR /&gt;sum + sumi;&lt;BR /&gt;put i=;&lt;BR /&gt;put sumi=;&lt;BR /&gt;end;&lt;BR /&gt;put sum=;&lt;BR /&gt;check = mod(sum,10);&lt;BR /&gt;put check=;&lt;BR /&gt;&lt;BR /&gt;if (int(check/10)+1)*10-check=substr(x,10,1) then do;&lt;BR /&gt;correct=1;&lt;BR /&gt;end;&lt;BR /&gt;else do;&lt;BR /&gt;correct=0;&lt;BR /&gt;end;&lt;BR /&gt;put correct=;&lt;BR /&gt;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 15 Jan 2016 16:18:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Modulus-10/m-p/243824#M6394</guid>
      <dc:creator>Uppiskalle</dc:creator>
      <dc:date>2016-01-15T16:18:31Z</dc:date>
    </item>
  </channel>
</rss>

