<?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: SAS programming &amp;quot;golf&amp;quot;: Find the fake books in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-Find-the-fake-books/m-p/949813#M371506</link>
    <description>I was not really playing just showing how to trim a few characters with&lt;BR /&gt;autocorrect. I copied your code but not the working version ##- Please type&lt;BR /&gt;your reply above this line. No attachments. -##</description>
    <pubDate>Sun, 03 Nov 2024 23:11:11 GMT</pubDate>
    <dc:creator>data_null__</dc:creator>
    <dc:date>2024-11-03T23:11:11Z</dc:date>
    <item>
      <title>SAS programming "golf": Find the fake books</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-Find-the-fake-books/m-p/948734#M371176</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-right" image-alt="[AI-generated Proc Studley]" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/101729i83D804B10616603D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Designer (2).jpeg" alt="[AI-generated Proc Studley]" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;[AI-generated Proc Studley]&lt;/span&gt;&lt;/span&gt;Here's the situation: The adventures of Proc Studley -- a popular Sci-Fi/Fantasy book series -- is under threat by a string of counterfeit/fake versions that have hit the marketplace. Your task is to find the fakes. All of the authentic books have valid&lt;A href="https://en.wikipedia.org/wiki/ISBN" target="_self" rel="nofollow noopener noreferrer"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;ISBN 10-digit numbers&lt;/A&gt;, which is how world libraries track books. The counterfeit books have &lt;STRONG&gt;invalid&lt;/STRONG&gt; ISBN values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(This challenge first premiered &lt;A href="https://explorers.sas.com/en/home.html" target="_self"&gt;in SAS Analytics Explorers&lt;/A&gt;, a special group for customers who want to do more with their SAS learning and earn rewards in the process!)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The algorithm for validating ISBN-10 values uses a checksum approach. Here are the steps:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Multiply &lt;STRONG&gt;each of the first&lt;/STRONG&gt; 9 digits by a number in the&lt;STRONG&gt; descending sequence&lt;/STRONG&gt; from 10 to 2, and &lt;STRONG&gt;sum&lt;/STRONG&gt; the results.&lt;/LI&gt;
&lt;LI&gt;Divide the sum by 11.&lt;/LI&gt;
&lt;LI&gt;Subtract the remainder (not the quotient) from 11.&lt;/LI&gt;
&lt;LI&gt;For the 10th digit, use the difference from the previous step. If that difference is 11, use the number 0; if 10, use the letter X.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Here are the book titles and their purported ISBN values. Write a &lt;STRONG&gt;the shortest possible&amp;nbsp;&lt;/STRONG&gt;SAS program that reads the book list, validates each ISBN value, and create a report of the real and fake books. Include your code and the output in your response!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;(Note: obviously all of these books are made up, but the ISBN number scheme and algorithm is a real thing! You can check your work ad hoc with &lt;A href="https://isbn-checker.netlify.app/" target="_self"&gt;the ISBN Checker&lt;/A&gt;.)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Here's the data, all ready to run in SAS.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;data isbn;
  infile datalines dsd;
  length title $ 70 isbn $ 10;
  input title isbn;
  datalines;
Proc Studley and the Starship of Destiny,0434488665
The Chronicles of Proc Studley: The Lost Realm,2018166516
Proc Studley and the Quantum Key,9405643837
The Legend of Proc Studley: The Celestial Quest,6032522768
Proc Studley and the Enchanted Nebula,4394205952
The Adventures of Proc Studley: The Galactic Rift,2353276079
Proc Studley and the Time Crystal,6493135591
The Saga of Proc Studley: The Forbidden Planet,6776994355
Proc Studley and the Alien Alliance,2227835451
The Epic of Proc Studley: The Cosmic War,8018735913
Proc Studley and the Dragon of Andromeda,0841779538
The Odyssey of Proc Studley: The Stellar Siege,8730652341
Proc Studley and the Phoenix Star,1594122350
The Journey of Proc Studley: The Nebula Nexus,224320418X
Proc Studley and the Shadow Realm,6857923406
The Quest of Proc Studley: The Celestial Citadel,3967006111
Proc Studley and the Interstellar Insurrection,9537581977
The Trials of Proc Studley: The Quantum Paradox,1283514257
Proc Studley and the Martian Rebellion,566485052X
The Legacy of Proc Studley: The Galactic Guardians,6994588902
Proc Studley and the Eternal Eclipse,9236137644
The Chronicles of Proc Studley: The Andromeda Enigma,7649918275
Proc Studley and the Infinite Horizon,458574645X
The Adventures of Proc Studley: The Alien Dawn,7601111520
Proc Studley and the Black Hole Conspiracy,1911465988
The Legend of Proc Studley: The Cosmic Code,266671036X
Proc Studley and the Celestial Shadows,4287030303
The Saga of Proc Studley: The Stellar Saga,2561407012
Proc Studley and the Quantum Quest,6933010252
The Epic of Proc Studley: The Celestial Conflict,4278675463
Proc Studley and the Galactic Gambit,351049735X
The Odyssey of Proc Studley: The Nebula Knights,0566910450
Proc Studley and the Cosmic Crusade,9802436077
The Journey of Proc Studley: The Andromeda Ascension,195432331X
Proc Studley and the Stellar Struggle,8421179217
The Quest of Proc Studley: The Alien Artifact,0979272564
Proc Studley and the Celestial Saga,3584795834
The Trials of Proc Studley: The Galactic Genesis,0713565068
Proc Studley and the Quantum Conundrum,9074601407
The Legacy of Proc Studley: The Cosmic Odyssey,0168786583
;
run;
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Oct 2024 16:14:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-Find-the-fake-books/m-p/948734#M371176</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2024-10-23T16:14:37Z</dc:date>
    </item>
    <item>
      <title>Re: SAS programming "golf": Find the fake books</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-Find-the-fake-books/m-p/948765#M371183</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data validation;
	set isbn;
	array _nine [9] (10, 9, 8, 7, 6, 5, 4, 3, 2);
	array nine [9];
	do i=1 to 9;
		nine{i}= input(substr(isbn,i, 1), best.)*_nine{i};
	end; 
	_sum=sum(of nine:);
	_remainder= mod(_sum, 11);
	result= 11-_remainder;
	if result eq 10 then isbn_validated= substr(isbn, 1, 9)||'X';
	else if result eq 11 then isbn_validated= substr(isbn, 1, 9)||'0';
	if isbn=isbn_validated;
	keep title isbn:;
run; 
proc print; run; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Real ones.&amp;nbsp;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 575px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/101734iFD1B012C981C11D0/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;BR /&gt;The remaining is fake.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Oct 2024 15:02:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-Find-the-fake-books/m-p/948765#M371183</guid>
      <dc:creator>A_Kh</dc:creator>
      <dc:date>2024-10-23T15:02:25Z</dc:date>
    </item>
    <item>
      <title>Re: SAS programming "golf": Find the fake books</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-Find-the-fake-books/m-p/948767#M371184</link>
      <description>&lt;P&gt;Good attempt&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/321371"&gt;@A_Kh&lt;/a&gt;&amp;nbsp;, but check your work! I think you've allowed&amp;nbsp;&lt;STRONG&gt;only&lt;/STRONG&gt; those that end with '0' or 'X'. There are actually several more valid ISBNs in the collection &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Oct 2024 15:11:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-Find-the-fake-books/m-p/948767#M371184</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2024-10-23T15:11:27Z</dc:date>
    </item>
    <item>
      <title>Re: SAS programming "golf": Find the fake books</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-Find-the-fake-books/m-p/948779#M371187</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4"&gt;@ChrisHemedinger&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-right" image-alt="[AI-generated Proc Studley]" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/101729i83D804B10616603D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Designer (2).jpeg" alt="[AI-generated Proc Studley]" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;[AI-generated Proc Studley]&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The algorithm for validating ISBN-10 values uses a checksum approach. Here are the steps:&lt;BR /&gt;....&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;For the 10th digit, if the summed result is 11, use the number 0; if 10, use the letter X.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;What would be the the 10th digit if the summed result is not in 10 or 11?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Oct 2024 15:46:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-Find-the-fake-books/m-p/948779#M371187</guid>
      <dc:creator>A_Kh</dc:creator>
      <dc:date>2024-10-23T15:46:00Z</dc:date>
    </item>
    <item>
      <title>Re: SAS programming "golf": Find the fake books</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-Find-the-fake-books/m-p/948784#M371188</link>
      <description>&lt;P&gt;My fault for not making it clear! The final checksum digit is the difference calculated in the previous step. If it's a 2-digit difference: for 11, use 0; for 10, use X. I edited the problem for clarity.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Oct 2024 16:16:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-Find-the-fake-books/m-p/948784#M371188</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2024-10-23T16:16:22Z</dc:date>
    </item>
    <item>
      <title>Re: SAS programming "golf": Find the fake books</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-Find-the-fake-books/m-p/948790#M371189</link>
      <description>&lt;P&gt;Edited based on the clarification:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data validation;
	set isbn;
	array _nine [9] (10, 9, 8, 7, 6, 5, 4, 3, 2);
	array nine [9];
	do i=1 to 9;
		nine{i}= input(substr(isbn,i, 1), best.)*_nine{i};
	end; 
	_sum=sum(of nine:);
	_remainder= mod(_sum, 11);
	result= 11-_remainder;
	if result eq 10 then checker= substr(isbn, 1, 9)||'X';
	else if result eq 11 then checker= substr(isbn, 1, 9)||'0';
	else checker= cats(substr(isbn, 1, 9), result);
	if isbn=checker then isbn_validated= 'Yes';
	else isbn_validated='No'; 
	if isbn_validated='No'; 
	keep title isbn:;
run; 

proc print; run; 
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Fake books&amp;nbsp; (N=19):&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 563px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/101741i7F249CB6270BFAF5/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Oct 2024 16:41:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-Find-the-fake-books/m-p/948790#M371189</guid>
      <dc:creator>A_Kh</dc:creator>
      <dc:date>2024-10-23T16:41:30Z</dc:date>
    </item>
    <item>
      <title>Re: SAS programming "golf": Find the fake books</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-Find-the-fake-books/m-p/948810#M371195</link>
      <description>&lt;P&gt;Here's another suggestion:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data;
set isbn;
s=0;
do j=1 to 9;
  s+j*input(char(isbn,j),1.);
end;
m=mod(s,11);
c=put(ifn(m=j,.X,m),1.)=char(isbn,j);
put isbn c;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The report is only suitable for internal purposes as it contains just the ISBNs and a "correctness flag" &lt;FONT face="courier new,courier"&gt;c&lt;/FONT&gt;, i.e., &lt;FONT face="courier new,courier"&gt;c=0&lt;/FONT&gt; indicates fake ISBNs, &lt;FONT face="courier new,courier"&gt;c=1&lt;/FONT&gt; correct ones:&lt;/P&gt;
&lt;PRE&gt;0434488665 0
2018166516 0
9405643837 0
6032522768 1
4394205952 0
2353276079 0
6493135591 1
6776994355 0
2227835451 1
8018735913 1
0841779538 1
8730652341 0
1594122350 1
224320418X 0
6857923406 0
3967006111 0
9537581977 1
1283514257 1
566485052X 0
6994588902 0
9236137644 1
7649918275 0
458574645X 0
7601111520 1
1911465988 1
266671036X 1
4287030303 1
2561407012 1
6933010252 1
4278675463 0
351049735X 1
0566910450 0
9802436077 0
195432331X 1
8421179217 1
0979272564 1
3584795834 1
0713565068 0
9074601407 0
0168786583 1
&lt;/PRE&gt;
&lt;P&gt;I used a bit of algebra to simplify the formulas.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Of course, the code could be shortened further. For example:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;At the cost of an even uglier report (but now including the book titles) one could replace "&lt;FONT face="courier new,courier"&gt;isbn c&lt;/FONT&gt;" by "&lt;FONT face="courier new,courier"&gt;_all_&lt;/FONT&gt;" in the final PUT statement.&lt;/LI&gt;
&lt;LI&gt;An ugly log could be achieved by omitting the INPUT function in the sum statement.&lt;/LI&gt;
&lt;LI&gt;The name of the input dataset could also be omitted &lt;U&gt;if&lt;/U&gt;&amp;nbsp;the code is submitted directly after the DATA step creating dataset ISBN (risky!).&lt;/LI&gt;
&lt;LI&gt;Sacrificing code readability, one could write all statements on the same line, without separating blanks, where possible.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;However, the resulting DATA step (containing 108 characters) violates so many coding standards that it must be hidden behind a spoiler.&lt;/P&gt;
&lt;LI-SPOILER&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data;set;s=0;do j=1to 9;s+j*char(isbn,j);end;m=mod(s,11);c=put(ifn(m=j,.X,m),1.)=char(isbn,j);put _all_;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/LI-SPOILER&gt;</description>
      <pubDate>Wed, 23 Oct 2024 19:42:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-Find-the-fake-books/m-p/948810#M371195</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2024-10-23T19:42:14Z</dc:date>
    </item>
    <item>
      <title>Re: SAS programming "golf": Find the fake books</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-Find-the-fake-books/m-p/948825#M371197</link>
      <description>&lt;P&gt;I know&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35763"&gt;@yabwon&lt;/a&gt;&amp;nbsp;is a fan of SAS Code Golf.&amp;nbsp; And he gave a couple solutions in the Analytics Explorers thread.&amp;nbsp; Maybe he'll take a swing at golfing this one.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Oct 2024 20:34:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-Find-the-fake-books/m-p/948825#M371197</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2024-10-23T20:34:42Z</dc:date>
    </item>
    <item>
      <title>Re: SAS programming "golf": Find the fake books</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-Find-the-fake-books/m-p/948886#M371221</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/19879"&gt;@Quentin&lt;/a&gt;&amp;nbsp;thanks for calling me out.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp;thanks for the algebra, I forgot that we are in Z11 &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If we are already in the realm of "breaking good programming practice" your already "skinny" solution could be boiled down by few bytes more, to 92, like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data;set;s=0;do j=1to 9;s+j*char(isbn,j);end;c=min(char(isbn,j),10)=mod(s,11);put _all_;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Of course the quiet assumption is that the ISBN dataset was created directly before that step;&lt;/P&gt;
&lt;P&gt;In the first test I was hoping to use &amp;gt;&amp;lt; operator (&amp;nbsp;&lt;CODE class=" language-sas"&gt;char(isbn,j)&amp;gt;&amp;lt;10&lt;/CODE&gt;&amp;nbsp;) but it's not "missing-value-proof"...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;User friendly version:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  set isbn;

  s=0;
  do j=1to 9;
    s+j*char(isbn,j);
  end;
  c=min(char(isbn,j),10)=mod(s,11);
  put _all_;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The version I started with was using CALL POKELONG to split ISBN variable into an array of values, but all I could do was 116 bytes&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data;set;array i[10]$1;CALL POKELONG(ISBN,ADDRLONG(i1),10);
s=0;do r=1to 9;s+i[r]*r;end;b=min(i[r],10)=mod(s,11);run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and it was with no "put _all_;" in the code, wit PUT it's +10&amp;nbsp;&lt;/P&gt;
&lt;P&gt;User friendly version:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test2; 
  set isbn;

  array i[10]$1;
  CALL POKELONG(ISBN,ADDRLONG(i1),10);

  s=0;
  do r=1to 9;
    s+i[r]*r;
  end;
  b=min(i[r],10)=mod(s,11);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;For 32 bit sas it could be 8 bytes shorter, because we could use CALL POKE() and ADDR().&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Will try to golf a bit more, but that 92 looks really hard.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Thu, 24 Oct 2024 13:41:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-Find-the-fake-books/m-p/948886#M371221</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2024-10-24T13:41:07Z</dc:date>
    </item>
    <item>
      <title>Re: SAS programming "golf": Find the fake books</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-Find-the-fake-books/m-p/948911#M371229</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35763"&gt;@yabwon&lt;/a&gt;: Very clever, as usual! This is a substantial shortening (which comes at the price of not recognizing an "ISBN" like "266671036&lt;STRONG&gt;Y&lt;/STRONG&gt;" as incorrect, but this was not a requirement). Other than the trivial replacement of the literal "&lt;FONT face="courier new,courier"&gt;10&lt;/FONT&gt;" by variable "&lt;FONT face="courier new,courier"&gt;j&lt;/FONT&gt;" (→ 91 characters) I don't see any room for further "improvement" at the moment.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Oct 2024 14:51:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-Find-the-fake-books/m-p/948911#M371229</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2024-10-24T14:51:36Z</dc:date>
    </item>
    <item>
      <title>Re: SAS programming "golf": Find the fake books</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-Find-the-fake-books/m-p/949805#M371502</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
  set isbn ;
  v = 0 ; keep title isbn v ;
  do i = 1 to 9 ; 
    length c $1 ; c = substr(isbn,i,1) ; if notdigit(c) then return ;
    vsum = sum(vsum,c*(11-i)) ;
  end;
  v = substr('1234567890X',11-mod(vsum,11)) =: substr(isbn,10,1) ;
run ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 03 Nov 2024 17:08:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-Find-the-fake-books/m-p/949805#M371502</guid>
      <dc:creator>RichardAD</dc:creator>
      <dc:date>2024-11-03T17:08:31Z</dc:date>
    </item>
    <item>
      <title>Re: SAS programming "golf": Find the fake books</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-Find-the-fake-books/m-p/949807#M371503</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;dat;se;arra i[10]$1;CAL POKELONG(ISBN,ADDRLONG(i1),10);
s=0;do r=1to 9;s+i[r]*r;en;b=min(i[r],10)=mod(s,11);ru;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Is this legal?&lt;/P&gt;</description>
      <pubDate>Sun, 03 Nov 2024 18:04:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-Find-the-fake-books/m-p/949807#M371503</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2024-11-03T18:04:45Z</dc:date>
    </item>
    <item>
      <title>Re: SAS programming "golf": Find the fake books</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-Find-the-fake-books/m-p/949808#M371504</link>
      <description>&lt;P&gt;You will need to correct the &lt;CODE&gt;s&lt;/CODE&gt; accumulation to&lt;/P&gt;
&lt;PRE&gt;s + i[r] * (11-r) ; ;&lt;/PRE&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;PRE&gt;s + i[10-r] * (r+1) ;&lt;/PRE&gt;
&lt;P&gt;And the code will not classify as valid ISBNs having an X checksum (for example &lt;CODE&gt;000000014X&lt;/CODE&gt;)&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 03 Nov 2024 18:59:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-Find-the-fake-books/m-p/949808#M371504</guid>
      <dc:creator>RichardAD</dc:creator>
      <dc:date>2024-11-03T18:59:31Z</dc:date>
    </item>
    <item>
      <title>Re: SAS programming "golf": Find the fake books</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-Find-the-fake-books/m-p/949811#M371505</link>
      <description>&lt;P&gt;Math is ok, and the code works well with "x", for example&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;000000014X
195432331X&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;the firs one is marked as invalid and the second as valid ISBN.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ISBN $10.;
cards;
000000014X
195432331X
run;

dat;se;arra i[10]$1;CAL POKELONG(ISBN,ADDRLONG(i1),10);
s=0;do r=1to 9;s+i[r]*r;en;b=min(i[r],10)=mod(s,11);ru;

proc print;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;result:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="yabwon_0-1730666913582.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/101948i2FB29F59E35D5403/image-size/medium?v=v2&amp;amp;px=400" role="button" title="yabwon_0-1730666913582.png" alt="yabwon_0-1730666913582.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 03 Nov 2024 20:48:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-Find-the-fake-books/m-p/949811#M371505</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2024-11-03T20:48:44Z</dc:date>
    </item>
    <item>
      <title>Re: SAS programming "golf": Find the fake books</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-Find-the-fake-books/m-p/949813#M371506</link>
      <description>I was not really playing just showing how to trim a few characters with&lt;BR /&gt;autocorrect. I copied your code but not the working version ##- Please type&lt;BR /&gt;your reply above this line. No attachments. -##</description>
      <pubDate>Sun, 03 Nov 2024 23:11:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-Find-the-fake-books/m-p/949813#M371506</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2024-11-03T23:11:11Z</dc:date>
    </item>
    <item>
      <title>Re: SAS programming "golf": Find the fake books</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-Find-the-fake-books/m-p/949815#M371507</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;v = substr('1234567890X',11-mod(vsum,11)) =: substr(isbn,10,1) ;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;has a bug. The 0X is transposed. It should be&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;v = substr('123456789X0',11-mod(vsum,11)) =: substr(isbn,10,1) ;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Based on the other solutions with&lt;CODE&gt;s+r*i[r]&lt;/CODE&gt;there seems to be a mathematical tautology.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="golf.png" style="width: 369px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/101949i635688C3DAA3069B/image-size/large?v=v2&amp;amp;px=999" role="button" title="golf.png" alt="golf.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;The righthand side being the algorithm steps stated initially.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Nov 2024 03:08:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-Find-the-fake-books/m-p/949815#M371507</guid>
      <dc:creator>RichardAD</dc:creator>
      <dc:date>2024-11-04T03:08:24Z</dc:date>
    </item>
    <item>
      <title>Re: SAS programming "golf": Find the fake books</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-Find-the-fake-books/m-p/949909#M371525</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/300781"&gt;@RichardAD&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Based on the other solutions with&lt;CODE&gt;s+r*i[r]&lt;/CODE&gt;there seems to be a mathematical tautology.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="golf.png" style="width: 369px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/101949i635688C3DAA3069B/image-size/large?v=v2&amp;amp;px=999" role="button" title="golf.png" alt="golf.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;The righthand side being the algorithm steps stated initially.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Unless you actually mean &lt;STRONG&gt;(&lt;/STRONG&gt;11 − (&lt;FONT face="symbol"&gt;S&lt;/FONT&gt;...)&lt;STRONG&gt;)&lt;/STRONG&gt; mod 11 on the right-hand side, it should rather be&amp;nbsp;&lt;STRONG&gt;(&lt;/STRONG&gt;11 − (&lt;FONT face="symbol"&gt;S&lt;/FONT&gt;...) mod 11&lt;STRONG&gt;) mod 11&lt;/STRONG&gt;, where the outer (...) mod 11 corresponds to the last bullet point in Chris' description of the algorithm. For example, if all &lt;EM&gt;d&lt;SUB&gt;i&lt;/SUB&gt;&lt;/EM&gt; are zero, the left-hand side is zero and so must be the right-hand side. The validity of the equation can be proved easily by applying the calculation rules of what mathematicians call the quotient ring &lt;STRONG&gt;Z&lt;/STRONG&gt;&lt;SUB&gt;11&lt;/SUB&gt;=&lt;STRONG&gt;Z&lt;/STRONG&gt;/11&lt;STRONG&gt;Z&lt;/STRONG&gt;.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Nov 2024 11:40:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-Find-the-fake-books/m-p/949909#M371525</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2024-11-05T11:40:12Z</dc:date>
    </item>
    <item>
      <title>Re: SAS programming "golf": Find the fake books</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-Find-the-fake-books/m-p/949913#M371526</link>
      <description>&lt;P&gt;The response here have been of very high quality. Proc Studley thanks you all for your service!&lt;/P&gt;</description>
      <pubDate>Tue, 05 Nov 2024 12:53:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-Find-the-fake-books/m-p/949913#M371526</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2024-11-05T12:53:44Z</dc:date>
    </item>
  </channel>
</rss>

