<?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: How to convert a character to ascii code in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-character-to-ascii-code/m-p/948844#M371209</link>
    <description>&lt;P&gt;The easiest way is to display the values in HEX instead of decimal.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input string $20.;
cards;
The rain in Spain
falls mainly on 
the plain.
;

data want;
  set have;
  codes = put(string,$hex40.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results&lt;/P&gt;
&lt;PRE&gt;Obs    string                                codes

 1     The rain in Spain    546865207261696E20696E20537061696E202020
 2     falls mainly on      66616C6C73206D61696E6C79206F6E2020202020
 3     the plain.           74686520706C61696E2E20202020202020202020

&lt;/PRE&gt;</description>
    <pubDate>Thu, 24 Oct 2024 00:41:41 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2024-10-24T00:41:41Z</dc:date>
    <item>
      <title>How to convert a character to ascii code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-character-to-ascii-code/m-p/948841#M371208</link>
      <description>&lt;P&gt;Hi experts&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'd like to convert a normal text to ascii code, for example: in my dataset I have the letter "t" and the value that i want is 116 and so on with the other letters or numbers.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;do you know a way to do it?&amp;nbsp; the final result that I want is a file in that format.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Oct 2024 00:27:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-character-to-ascii-code/m-p/948841#M371208</guid>
      <dc:creator>Jose7</dc:creator>
      <dc:date>2024-10-24T00:27:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert a character to ascii code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-character-to-ascii-code/m-p/948844#M371209</link>
      <description>&lt;P&gt;The easiest way is to display the values in HEX instead of decimal.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input string $20.;
cards;
The rain in Spain
falls mainly on 
the plain.
;

data want;
  set have;
  codes = put(string,$hex40.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results&lt;/P&gt;
&lt;PRE&gt;Obs    string                                codes

 1     The rain in Spain    546865207261696E20696E20537061696E202020
 2     falls mainly on      66616C6C73206D61696E6C79206F6E2020202020
 3     the plain.           74686520706C61696E2E20202020202020202020

&lt;/PRE&gt;</description>
      <pubDate>Thu, 24 Oct 2024 00:41:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-character-to-ascii-code/m-p/948844#M371209</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-10-24T00:41:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert a character to ascii code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-character-to-ascii-code/m-p/948845#M371210</link>
      <description>&lt;P&gt;The rank function returns the ascii code for a character.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  file print;
  ascii_code=rank('t');
  put ascii_code;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_1-1729730268882.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/101758i75DCE3E348991CA4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_1-1729730268882.png" alt="Patrick_1-1729730268882.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;the final result that I want is a file in that format.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Like a text file with all the characters replaced with their respective ASCII code? And I guess that all ASCII codes would need to take-up 3 positions so you know where they start and end.&lt;/P&gt;
&lt;P&gt;Why ASCII codes which is very unusual and not HEX values?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;....and just thinking: May-be tell us what the purpose for such conversion is. There might be other ways for achieving the same goal.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Oct 2024 00:45:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-character-to-ascii-code/m-p/948845#M371210</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-10-24T00:45:29Z</dc:date>
    </item>
  </channel>
</rss>

