<?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: Find the ASCII code of a character in IML in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Find-the-ASCII-code-of-a-character-in-IML/m-p/103419#M764</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You title suggests that you want to find the ascii code. Try this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ascii = byte(65:122);&lt;/P&gt;&lt;P&gt;label = "A65":"A122";&lt;/P&gt;&lt;P&gt;print ascii[colname=label];&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 07 Aug 2013 11:07:47 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2013-08-07T11:07:47Z</dc:date>
    <item>
      <title>Find the ASCII code of a character in IML</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Find-the-ASCII-code-of-a-character-in-IML/m-p/103416#M761</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This should be simple, but I just can't see it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What is the best way to replicate the functionality of the data-step RANK function from within IML? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Using syntax such as rank('G') results in the error, "Character operation not implemented yet", which I presume is referring to the IML RANK function not being able to handle a character matrix.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ian.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Aug 2013 09:27:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Find-the-ASCII-code-of-a-character-in-IML/m-p/103416#M761</guid>
      <dc:creator>IanWakeling</dc:creator>
      <dc:date>2013-08-07T09:27:05Z</dc:date>
    </item>
    <item>
      <title>Re: Find the ASCII code of a character in IML</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Find-the-ASCII-code-of-a-character-in-IML/m-p/103417#M762</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ian,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You&amp;nbsp; might find the following link interesting.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="active_link" href="http://support.sas.com/documentation/cdl/en/imlug/63541/HTML/default/viewer.htm#imlug_langref_sect235.htm" title="http://support.sas.com/documentation/cdl/en/imlug/63541/HTML/default/viewer.htm#imlug_langref_sect235.htm"&gt;SAS/IML(R) 9.22 User's Guide&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Specifically the section referring to the following code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* Create RANK-like functionality for character matrices */&lt;/P&gt;&lt;P&gt;start rankc(x);&lt;/P&gt;&lt;P&gt;&amp;nbsp; s = unique(x); /* the unique function returns a sorted list */&lt;/P&gt;&lt;P&gt;&amp;nbsp; idx = j(nrow(x), ncol(x));&lt;/P&gt;&lt;P&gt;&amp;nbsp; ctr = 1; /* there can be duplicate values in x */&lt;/P&gt;&lt;P&gt;&amp;nbsp; do i = 1 to ncol(s); /* for each unique value */&lt;/P&gt;&lt;P&gt;&amp;nbsp; t = loc(x = s&lt;I&gt;);&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; nDups = ncol(t);&lt;/P&gt;&lt;P&gt;&amp;nbsp; idx&lt;T&gt; = ctr : ctr+nDups-1;&lt;/T&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; ctr = ctr + nDups;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; return (idx);&lt;/P&gt;&lt;P&gt;finish;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* call the RANKC module */&lt;/P&gt;&lt;P&gt;x = {every good boy does fine and good and well every day};&lt;/P&gt;&lt;P&gt;rc = rankc(x);&lt;/P&gt;&lt;P&gt;print rc[colnam=x];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* Notice that ranking is in ASCII order, in which capital&lt;/P&gt;&lt;P&gt;&amp;nbsp; letters precede lower case letters. To get case-insensitive&lt;/P&gt;&lt;P&gt;&amp;nbsp; behavior, transform the matrix before comparison */&lt;/P&gt;&lt;P&gt;x = {"a" "b" "X" "Y" };&lt;/P&gt;&lt;P&gt;asciiOrder = rankc(x);&lt;/P&gt;&lt;P&gt;alphaOrder = rankc(upcase(x));&lt;/P&gt;&lt;P&gt;print x, asciiOrder, alphaOrder;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Aug 2013 09:43:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Find-the-ASCII-code-of-a-character-in-IML/m-p/103417#M762</guid>
      <dc:creator>Scott_Mitchell</dc:creator>
      <dc:date>2013-08-07T09:43:22Z</dc:date>
    </item>
    <item>
      <title>Re: Find the ASCII code of a character in IML</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Find-the-ASCII-code-of-a-character-in-IML/m-p/103418#M763</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Scott,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks, but I am not looking to get the rank order of all the elements in a character matrix.&amp;nbsp; In a data-step rank('G') returns&amp;nbsp; 71, the character code for the letter G, I am looking for the equivalent of that in IML.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Aug 2013 11:01:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Find-the-ASCII-code-of-a-character-in-IML/m-p/103418#M763</guid>
      <dc:creator>IanWakeling</dc:creator>
      <dc:date>2013-08-07T11:01:24Z</dc:date>
    </item>
    <item>
      <title>Re: Find the ASCII code of a character in IML</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Find-the-ASCII-code-of-a-character-in-IML/m-p/103419#M764</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You title suggests that you want to find the ascii code. Try this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ascii = byte(65:122);&lt;/P&gt;&lt;P&gt;label = "A65":"A122";&lt;/P&gt;&lt;P&gt;print ascii[colname=label];&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Aug 2013 11:07:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Find-the-ASCII-code-of-a-character-in-IML/m-p/103419#M764</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2013-08-07T11:07:47Z</dc:date>
    </item>
    <item>
      <title>Re: Find the ASCII code of a character in IML</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Find-the-ASCII-code-of-a-character-in-IML/m-p/103420#M765</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Rick,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have gone with&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;start char_rank(c);&lt;/P&gt;&lt;P&gt;&amp;nbsp; ascii = byte(65:122);&lt;/P&gt;&lt;P&gt;&amp;nbsp; return( loc( ascii = c) + 64);&lt;/P&gt;&lt;P&gt;finish;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;it will work for what I have in mind as I know c will always be a single letter.&amp;nbsp; I was kind of hoping that since BYTE was available, then there should be a way to get the inverse function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ian. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Aug 2013 12:19:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Find-the-ASCII-code-of-a-character-in-IML/m-p/103420#M765</guid>
      <dc:creator>IanWakeling</dc:creator>
      <dc:date>2013-08-07T12:19:45Z</dc:date>
    </item>
    <item>
      <title>Re: Find the ASCII code of a character in IML</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Find-the-ASCII-code-of-a-character-in-IML/m-p/103421#M766</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sounds good. Here's a cute idea that falls into the "isn't that interesting" category. It maps each alphabetical value (no punctuation) to the ascii code for the uppercase version of the letter:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;asciiVals = 65:90;&lt;/P&gt;&lt;P&gt;letters = byte(asciiVals);&lt;/P&gt;&lt;P&gt;mattrib asciiVals colname=letters;&lt;/P&gt;&lt;P&gt;str = {I A N W A K E L I N G};&lt;/P&gt;&lt;P&gt;b = asciiVals[,str];&lt;/P&gt;&lt;P&gt;print b;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Probably not useful for your application, but fun. For more on the MATTRIB function, see &lt;A href="http://blogs.sas.com/content/iml/2012/10/01/access-rows-or-columns-of-a-matrix-by-names/" title="http://blogs.sas.com/content/iml/2012/10/01/access-rows-or-columns-of-a-matrix-by-names/"&gt; Access rows or columns of a matrix by names - The DO Loop&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Aug 2013 11:36:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Find-the-ASCII-code-of-a-character-in-IML/m-p/103421#M766</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2013-08-08T11:36:15Z</dc:date>
    </item>
    <item>
      <title>Re: Find the ASCII code of a character in IML</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Find-the-ASCII-code-of-a-character-in-IML/m-p/103422#M767</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That's a very nice and a unintended use of mattrib.&amp;nbsp; Unfortunately my application has lower case letters as well otherwise I would use it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The character data that I want to convert comes in blocks of letters without delimiters and I find that I need to chop the blocks into individual characters as you have done with my name above.&amp;nbsp;&amp;nbsp; There is no need to loop over each character in the string, as I have found that I can do this as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;start chop(s);&lt;BR /&gt;&amp;nbsp; call execute( cat( 'chopstr = {', prxchange( "s/(.)/'$1' /", -1, s), '};') );&lt;BR /&gt;&amp;nbsp; return(chopstr);&lt;BR /&gt;finish;&lt;/P&gt;&lt;P&gt;str=chop('IanWakeling');&lt;BR /&gt;print str;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;By the way, it is not possible to use a call execute to return from a function module - I tried!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Aug 2013 13:09:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Find-the-ASCII-code-of-a-character-in-IML/m-p/103422#M767</guid>
      <dc:creator>IanWakeling</dc:creator>
      <dc:date>2013-08-09T13:09:38Z</dc:date>
    </item>
    <item>
      <title>Re: Find the ASCII code of a character in IML</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Find-the-ASCII-code-of-a-character-in-IML/m-p/103423#M768</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you have SAS/IML 12.1, you can use a &lt;A href="http://support.sas.com/documentation/cdl/en/imlug/66112/HTML/default/viewer.htm#imlug_whatsnew9_sect002.htm"&gt;new feature of the SUBSTR function&lt;/A&gt;:&lt;/P&gt;&lt;P&gt;start chop(s);&lt;/P&gt;&lt;P&gt;&amp;nbsp; return ( substr(s, 1:nleng(s), 1) );&lt;/P&gt;&lt;P&gt;finish;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Aug 2013 14:17:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Find-the-ASCII-code-of-a-character-in-IML/m-p/103423#M768</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2013-08-09T14:17:17Z</dc:date>
    </item>
    <item>
      <title>Re: Find the ASCII code of a character in IML</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Find-the-ASCII-code-of-a-character-in-IML/m-p/103424#M769</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That's a lot nicer, I shall have to look into upgrading.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Aug 2013 14:40:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Find-the-ASCII-code-of-a-character-in-IML/m-p/103424#M769</guid>
      <dc:creator>IanWakeling</dc:creator>
      <dc:date>2013-08-09T14:40:45Z</dc:date>
    </item>
    <item>
      <title>Re: Find the ASCII code of a character in IML</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Find-the-ASCII-code-of-a-character-in-IML/m-p/103425#M770</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here's one you can use without upgrading:&lt;/P&gt;&lt;P&gt;start chop(s);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; return( cshape(s,1,nleng(s),1) );&lt;/P&gt;&lt;P&gt;finish;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Aug 2013 19:02:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Find-the-ASCII-code-of-a-character-in-IML/m-p/103425#M770</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2013-08-14T19:02:17Z</dc:date>
    </item>
    <item>
      <title>Re: Find the ASCII code of a character in IML</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Find-the-ASCII-code-of-a-character-in-IML/m-p/103426#M771</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Rick, that's cool.&amp;nbsp;&amp;nbsp; I never looked at cshape before.&amp;nbsp; The assumption would be that the functionality is similar to the regular shape function, but the size parameter makes it more powerful as you have shown.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Aug 2013 11:20:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Find-the-ASCII-code-of-a-character-in-IML/m-p/103426#M771</guid>
      <dc:creator>IanWakeling</dc:creator>
      <dc:date>2013-08-15T11:20:36Z</dc:date>
    </item>
    <item>
      <title>Re: Find the ASCII code of a character in IML</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Find-the-ASCII-code-of-a-character-in-IML/m-p/729439#M5439</link>
      <description>&lt;P&gt;Another way to do it would be to use the pib1. format.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;n = inputn("A","pib1.");&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Mar 2021 16:24:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Find-the-ASCII-code-of-a-character-in-IML/m-p/729439#M5439</guid>
      <dc:creator>ArinC</dc:creator>
      <dc:date>2021-03-26T16:24:20Z</dc:date>
    </item>
  </channel>
</rss>

