<?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;: highest digit in a string of digits in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-highest-digit-in-a-string-of/m-p/480049#M124024</link>
    <description>&lt;P&gt;Chris,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Brevity is important, especially since it is the stated goal of the challenge. But there's another aspect. Golf is little fun if you have to crawl from hole to hole, even if you end up well under par. Here, too, it matters how fast different approaches get there. In this respect, not only FreelanceReinhard's method is the tersest but it outperforms any other technique hands down. I had suspected it was the case because SAS string search functions are based on an extremely rapid underlying algorithm - but didn't know by how much before testing it. The step below tests the FINDC approach, the APP approach, and the loop approach.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The result is that the run times for the four methods (in the order listed above) are related as 1:10:15. Ten times is a pretty astounding difference between FINDC and the next fastest method, the APP. The latter would probably fare faster if it didn't have to do the implicit character-to-numeric type conversions. It also shows how relatively slow the combination of looping and the CHAR function is.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;On a different note, I see nothing inherently "dangerous" in CALL POKE(LONG) and have used it to speed things up (including in production under W, U/L, and z/OS) since at least 1998 (and even penned a few papers on the subject). At any rate, it's totally safe to write to an address already occupied by an element of a temp array - which also guarantees that address-wise, adjacent elements abut each other in physical memory. (Note how this circumstance is exploited below to populate all bytes of N L-long elements of a temp array with random digits without a need to loop through the array itself.)&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;Paul D.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let N =   100 ; /* Number of random strings to test */                               
%let L =    32 ; /* Length of each string            */                               
%let R = 10000 ; /* Number of test repetitions       */                               
                                                                                      
data _null_ ;                                                                         
  array ss [&amp;amp;N] $ &amp;amp;L _temporary_ ;                                                    
  /* Populate each L-long string with random digits from 0 to 9 */              
  call streaminit (7) ;                                                               
  x = addrlong (ss[1]) ;                                                              
  do j = 1 to &amp;amp;N * &amp;amp;L ;                                                               
    call pokelong  (put (rand ("uniform", 0, 9), 1.), ptrlongadd (x, j - 1), 1) ;     
  end ;                                                                               
  /* FINDC approach */                                                                
  t = time() ;                                                                        
  do r = 1 to &amp;amp;R ;                                                                    
    do j = 1 to &amp;amp;N ;                                                                  
      max = findc ("123456789", ss[j], -9) ;                                          
    end ;                                                                             
  end ;                                                                               
  t1 = time() - t ;                                                                   
  /* APP approach - note implicit type conversions */                                 
  t = time() ;                                                                        
  array cc [&amp;amp;L] $ 1 _temporary_ ;                                                     
  do r = 1 to &amp;amp;R ;                                                                    
    do j = 1 to &amp;amp;N ;                                                                  
      call pokelong (ss[j], addrlong (cc[1]), &amp;amp;L) ;                                   
      max = max (of cc[*]) ;                                                          
    end ;                                                                             
  end ;                                                                               
  t2 = time() - t ;                                                                   
  /* Loop approach - $1-to-$1 comparison with conversion */                           
  t = time() ;                                                                        
  do r = 1 to &amp;amp;R ;                                                                    
    do j = 1 to &amp;amp;N ;                                                                  
      cm = "0" ;                                                                      
      do i = 1 to &amp;amp;L ;                                                                
        cm = cm &amp;lt;&amp;gt; char (ss[j], i) ;                                                  
      end ;                                                                           
      max = input (cm, 1.) ;                                                          
    end ;                                                                             
  end ;                                                                               
  t3 = time() - t ;                                                                   
                                                                                      
  rel_time = catx (":", 1, round (t2/t1), round (t3/t1)) ;                            
  put rel_time ;                                                                      
run ;                                                                                 &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 21 Jul 2018 06:12:17 GMT</pubDate>
    <dc:creator>hashman</dc:creator>
    <dc:date>2018-07-21T06:12:17Z</dc:date>
    <item>
      <title>SAS programming "golf": highest digit in a string of digits</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-highest-digit-in-a-string-of/m-p/479121#M123621</link>
      <description>&lt;P&gt;This question came in for&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13728"&gt;@SASJedi&lt;/a&gt;&amp;nbsp;and me on Twitter:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;You have a character var with the string "000112010302". What's the least about of [SAS] code that can be written to determine what is the highest number (3) in the string?&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;I have an answer that works, but I'm certain it isn't the least amount of code possible.&amp;nbsp; I figured that I'd post to the community and learn something.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Chris&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jul 2018 16:15:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-highest-digit-in-a-string-of/m-p/479121#M123621</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2018-07-18T16:15:41Z</dc:date>
    </item>
    <item>
      <title>Re: SAS programming "golf": highest digit in a string of digits</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-highest-digit-in-a-string-of/m-p/479137#M123627</link>
      <description>&lt;P&gt;My stab&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data w;
k="000112010302";
do _n_=1 to length(k);
highest=max(highest,char(k,_n_));
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 18 Jul 2018 16:48:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-highest-digit-in-a-string-of/m-p/479137#M123627</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-07-18T16:48:21Z</dc:date>
    </item>
    <item>
      <title>Re: SAS programming "golf": highest digit in a string of digits</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-highest-digit-in-a-string-of/m-p/479147#M123631</link>
      <description>&lt;P&gt;Well, I'm not sure that can be beat here.&amp;nbsp; Here was mine, but it's a few lines longer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%macro m();
data q;
s = '000112010302';
%do i = 1 %to 12;
c&amp;amp;i. = substr(s,&amp;amp;i.,1);
%end;
max = max(of c1-c12);
drop c1-c12 i;
run;
%mend;
%m;&lt;/PRE&gt;</description>
      <pubDate>Wed, 18 Jul 2018 17:11:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-highest-digit-in-a-string-of/m-p/479147#M123631</guid>
      <dc:creator>ProcWes</dc:creator>
      <dc:date>2018-07-18T17:11:59Z</dc:date>
    </item>
    <item>
      <title>Re: SAS programming "golf": highest digit in a string of digits</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-highest-digit-in-a-string-of/m-p/479152#M123633</link>
      <description>&lt;P&gt;Well,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/151081"&gt;@ProcWes&lt;/a&gt;, it looks like you've been lured by the siren song of SAS macro.&amp;nbsp; Macro is tempting for its reusability, but if you turned on MPRINT you'd see that this code actually generates a lot more statements.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If we allow that we know the length of the string going in, then we can use the &lt;STRONG&gt;max of&amp;nbsp;&lt;/STRONG&gt;construct&amp;nbsp;as you've done.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
 c = '000112010302';
 array chars{12} 3;
 do i = 1 to length(c);
  chars(i) = input(substr(c,i,1),1.);
 end;
 answer = max(of chars[*]);
 put answer=;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But so far&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;has got these both beat.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suspect that SAS/IML can probably do even better -- load the chars into a matrix and then get the max.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jul 2018 17:29:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-highest-digit-in-a-string-of/m-p/479152#M123633</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2018-07-18T17:29:19Z</dc:date>
    </item>
    <item>
      <title>Re: SAS programming "golf": highest digit in a string of digits</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-highest-digit-in-a-string-of/m-p/479155#M123635</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4"&gt;@ChrisHemedinger&lt;/a&gt;- yeah, I just wanted the c&amp;amp;i loop to work horizontally.&amp;nbsp; If I do a regular do, I can't get that - it executes vertically. (i can't reference the "i" value for the variable name.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't use arrays enough to set it up, but i'm not surprised there is an option there.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jul 2018 17:27:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-highest-digit-in-a-string-of/m-p/479155#M123635</guid>
      <dc:creator>ProcWes</dc:creator>
      <dc:date>2018-07-18T17:27:50Z</dc:date>
    </item>
    <item>
      <title>Re: SAS programming "golf": highest digit in a string of digits</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-highest-digit-in-a-string-of/m-p/479179#M123643</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
 str='000112010302';
 maximum=max((substr(str,1:length(str),1)));
 print maximum;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here's my crack at it in IML. Credit the assist to &lt;A href="https://blogs.sas.com/content/iml/2014/05/05/iml-character-vectors.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2014/05/05/iml-character-vectors.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jul 2018 18:08:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-highest-digit-in-a-string-of/m-p/479179#M123643</guid>
      <dc:creator>ChanceTGardener</dc:creator>
      <dc:date>2018-07-18T18:08:54Z</dc:date>
    </item>
    <item>
      <title>Re: SAS programming "golf": highest digit in a string of digits</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-highest-digit-in-a-string-of/m-p/479180#M123644</link>
      <description>&lt;P&gt;How about this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%sysfunc(findc(123456789,000112010302,b));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or, in a data step:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data;
c='000112010302';
h=findc('123456789',c,-9);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(Edit: replaced &lt;FONT face="courier new,courier"&gt;'b'&lt;/FONT&gt; by &lt;FONT face="courier new,courier"&gt;-9&lt;/FONT&gt;&amp;nbsp;in the data step to save one more character)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit 2: At the cost of readability, one could replace &lt;FONT face="courier new,courier"&gt;'123456789'&lt;/FONT&gt; with&amp;nbsp;&lt;FONT face="courier new,courier"&gt;1e10/81-1&lt;/FONT&gt; (two characters less).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;Editor's note:&lt;/STRONG&gt; this was the earliest, best solution that came in -- so it's the Accepted Solution.&amp;nbsp; But it's worth reading through ALL of the responses to learn about different approaches and pick up several "tricks" to make SAS do your bidding.&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Aug 2018 17:17:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-highest-digit-in-a-string-of/m-p/479180#M123644</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-08-15T17:17:09Z</dc:date>
    </item>
    <item>
      <title>Re: SAS programming "golf": highest digit in a string of digits</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-highest-digit-in-a-string-of/m-p/479215#M123656</link>
      <description>&lt;P&gt;Chance beat me to the punch. Not sure what the rules are ... do we just need to compute it? Print it?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
k="000112010302";
m=max(substr(k,1:nleng(k),1));


/* OR if need print */

proc iml;
k="000112010302";
print (max(substr(k,1:nleng(k),1)));
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 18 Jul 2018 19:07:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-highest-digit-in-a-string-of/m-p/479215#M123656</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2018-07-18T19:07:07Z</dc:date>
    </item>
    <item>
      <title>Re: SAS programming "golf": highest digit in a string of digits</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-highest-digit-in-a-string-of/m-p/479275#M123672</link>
      <description>&lt;P&gt;Here is another Base SAS approach using the APP functions&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
    array ct [20] $1 _temporary_ ; /* Changing the size of the array elements, allows you to compare 2,3,.. digits */
    call pokelong ("000112010302",addrlong(ct[1]),length("000112010302"));
    max=max(of ct{*});
    put max=;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Ahmed&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jul 2018 21:07:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-highest-digit-in-a-string-of/m-p/479275#M123672</guid>
      <dc:creator>AhmedAl_Attar</dc:creator>
      <dc:date>2018-07-18T21:07:38Z</dc:date>
    </item>
    <item>
      <title>Re: SAS programming "golf": highest digit in a string of digits</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-highest-digit-in-a-string-of/m-p/479308#M123687</link>
      <description>&lt;P&gt;It doesn't get any terser and more ingenious than that. Kudos.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jul 2018 22:16:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-highest-digit-in-a-string-of/m-p/479308#M123687</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2018-07-18T22:16:54Z</dc:date>
    </item>
    <item>
      <title>Re: SAS programming "golf": highest digit in a string of digits</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-highest-digit-in-a-string-of/m-p/479312#M123688</link>
      <description>&lt;P&gt;Chris,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Methinks&amp;nbsp;FreelanceReinhard clearly wins this race since his offer doesn't even require looping. With a loop, infinite variants are possible. For example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data _null_ ;                           
  c = '000112010302' ;                  
  do j = 0 to 9 until (length (c) = 1) ;
    c = compress (c, put (j, 1.)) ;     
  end ;                                 
  put c= ;                              
run;                                    &lt;/PRE&gt;&lt;P&gt;Or just:&lt;/P&gt;&lt;PRE&gt;data _null_ ;                         
  c = '000112010302' ;                
  do j = 1 to length (c) ;            
    d = d &amp;lt;&amp;gt; input (char (c, j), 1.) ;
  end ;                               
  put d=;                             
run;                                  &lt;/PRE&gt;&lt;P&gt;And so forth ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Paul D.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jul 2018 22:55:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-highest-digit-in-a-string-of/m-p/479312#M123688</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2018-07-18T22:55:38Z</dc:date>
    </item>
    <item>
      <title>Re: SAS programming "golf": highest digit in a string of digits</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-highest-digit-in-a-string-of/m-p/479317#M123692</link>
      <description>&lt;P&gt;How about this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  do i=9 to 0 by -1 while (x=.);
    if indexc(k,put(i,z1.)) then x=i ;
  end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;223  data have;
224    k="000112010302";
225    do i=9 to 0 by -1 while (x=.);
226      if indexc(k,put(i,z1.)) then x=i ;
227    end;
228    put k=:$quote. x= ;
229  run;

k="000112010302" x=3&lt;/PRE&gt;</description>
      <pubDate>Wed, 18 Jul 2018 23:42:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-highest-digit-in-a-string-of/m-p/479317#M123692</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-07-18T23:42:06Z</dc:date>
    </item>
    <item>
      <title>Re: SAS programming "golf": highest digit in a string of digits</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-highest-digit-in-a-string-of/m-p/479321#M123695</link>
      <description>&lt;P&gt;That might be the shortest, but it doesn't handle an empty string properly.&amp;nbsp; It treats a missing string as if it was all 0 digits.&lt;/P&gt;
&lt;P&gt;Here is a version using FINDC() that returns -1 for missing strings.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input k $12.;
  x=10-findc('9876543210 ',k);
  y=findc('123456789',k,-9);
  put k $12. +1 x= y=;
cards;
000112010302
0
1
2
3
4
5
6
7
8
9
0123456789
.
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jul 2018 00:08:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-highest-digit-in-a-string-of/m-p/479321#M123695</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-07-19T00:08:16Z</dc:date>
    </item>
    <item>
      <title>Re: SAS programming "golf": highest digit in a string of digits</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-highest-digit-in-a-string-of/m-p/479322#M123696</link>
      <description>&lt;P&gt;Are we allowed to assume we have an autocall library?&lt;/P&gt;
&lt;PRE&gt;608  data want;
609    x=%x(000112010302);
610    put x=;
611  run;

x=3&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 Jul 2018 00:18:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-highest-digit-in-a-string-of/m-p/479322#M123696</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-07-19T00:18:34Z</dc:date>
    </item>
    <item>
      <title>Re: SAS programming "golf": highest digit in a string of digits</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-highest-digit-in-a-string-of/m-p/479370#M123723</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input k $12.;
cards;
000112010302
0
1
2
3
4
5
6
7
8
9
0123456789
.
;

data w;
set have;
k1=compress('9876543210',k,'k');   
want=char(k1,1);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;cleaned further with first function wrapper:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data w;
set have;
want=first(compress('9876543210',k,'k'));  
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jul 2018 04:46:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-highest-digit-in-a-string-of/m-p/479370#M123723</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-07-19T04:46:48Z</dc:date>
    </item>
    <item>
      <title>Re: SAS programming "golf": highest digit in a string of digits</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-highest-digit-in-a-string-of/m-p/479425#M123755</link>
      <description>&lt;P&gt;Thanks a lot for chiming in, Paul. This is a great honor.&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;&lt;FONT size="1 2 3 4 5 6 7"&gt;I'm hesitant to point out that the UNTIL condition &lt;FONT face="courier new,courier"&gt;length (c) = 1&lt;/FONT&gt; would not be effective in the case of a tie.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jul 2018 09:02:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-highest-digit-in-a-string-of/m-p/479425#M123755</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-07-19T09:02:02Z</dc:date>
    </item>
    <item>
      <title>Re: SAS programming "golf": highest digit in a string of digits</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-highest-digit-in-a-string-of/m-p/479449#M123768</link>
      <description>&lt;P&gt;The honor more than deserved.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And you shouldn't be hesitant about the UNTIL. Thou art speaketh the truth.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jul 2018 10:31:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-highest-digit-in-a-string-of/m-p/479449#M123768</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2018-07-19T10:31:02Z</dc:date>
    </item>
    <item>
      <title>Re: SAS programming "golf": highest digit in a string of digits</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-highest-digit-in-a-string-of/m-p/479469#M123778</link>
      <description>&lt;P&gt;You are a code poet, sir! Nicely done.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jul 2018 12:42:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-highest-digit-in-a-string-of/m-p/479469#M123778</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2018-07-19T12:42:16Z</dc:date>
    </item>
    <item>
      <title>Re: SAS programming "golf": highest digit in a string of digits</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-highest-digit-in-a-string-of/m-p/479476#M123783</link>
      <description>&lt;P&gt;Maybe not the shortest, but I haven't seen POKE used in a long time.&amp;nbsp;That was fun! &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;</description>
      <pubDate>Thu, 19 Jul 2018 13:08:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-highest-digit-in-a-string-of/m-p/479476#M123783</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2018-07-19T13:08:49Z</dc:date>
    </item>
    <item>
      <title>Re: SAS programming "golf": highest digit in a string of digits</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-highest-digit-in-a-string-of/m-p/479477#M123784</link>
      <description>&lt;P&gt;That's a pretty sweet solution &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;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jul 2018 13:10:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-quot-golf-quot-highest-digit-in-a-string-of/m-p/479477#M123784</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2018-07-19T13:10:52Z</dc:date>
    </item>
  </channel>
</rss>

