<?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: change the last digit alphabet A to the number 0 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/change-the-last-digit-alphabet-A-to-the-number-0/m-p/762333#M241354</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/56484"&gt;@Ron_Cody&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Here is a really interesting solution that uses the SUBSTR function on the LEFT side of the = sign.&amp;nbsp; I assume you mean the digit 0 (character) for the last position.&amp;nbsp; Here it is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;data Test;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;length String $ 11;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;input String;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;substr(String,11,1) = '0';&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;datalines;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;SGJ604-01-A&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;AFD345-03-A&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;title "Listing of Test";&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;proc print data=Test;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;run;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Hope this helps,&lt;/P&gt;
&lt;P&gt;Ron&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That unconditionally changes the character to 0. OP only wants the last character to change when it is 'A'&lt;/P&gt;</description>
    <pubDate>Wed, 18 Aug 2021 16:28:02 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2021-08-18T16:28:02Z</dc:date>
    <item>
      <title>change the last digit alphabet A to the number 0</title>
      <link>https://communities.sas.com/t5/SAS-Programming/change-the-last-digit-alphabet-A-to-the-number-0/m-p/762290#M241330</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have a data with the following ID's&lt;/P&gt;&lt;P&gt;SGJ604-01-A&lt;/P&gt;&lt;P&gt;AFD345-03-A&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to change the last alphabet "A" to the number "0"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can I do this in SAS. please let me know thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Aug 2021 14:50:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/change-the-last-digit-alphabet-A-to-the-number-0/m-p/762290#M241330</guid>
      <dc:creator>Smitha9</dc:creator>
      <dc:date>2021-08-18T14:50:44Z</dc:date>
    </item>
    <item>
      <title>Re: change the last digit alphabet A to the number 0</title>
      <link>https://communities.sas.com/t5/SAS-Programming/change-the-last-digit-alphabet-A-to-the-number-0/m-p/762293#M241331</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; if char(id,length(id))='A' then substr(id,length(id))='0';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;458   data want;
459    set have;
460    put id= '-&amp;gt; ' @;
461    if char(id,length(id))='A' then substr(id,length(id))='0';
462    put id;
463   run;

id=SGJ604-01-A -&amp;gt; SGJ604-01-0
id=SGJ604-02-B -&amp;gt; SGJ604-02-B
id=AFD345-03-A -&amp;gt; AFD345-03-0
&lt;/PRE&gt;</description>
      <pubDate>Wed, 18 Aug 2021 14:55:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/change-the-last-digit-alphabet-A-to-the-number-0/m-p/762293#M241331</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-08-18T14:55:08Z</dc:date>
    </item>
    <item>
      <title>Re: change the last digit alphabet A to the number 0</title>
      <link>https://communities.sas.com/t5/SAS-Programming/change-the-last-digit-alphabet-A-to-the-number-0/m-p/762307#M241338</link>
      <description>&lt;P&gt;Here is a really interesting solution that uses the SUBSTR function on the LEFT side of the = sign.&amp;nbsp; I assume you mean the digit 0 (character) for the last position.&amp;nbsp; Here it is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;data Test;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;length String $ 11;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;input String;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;substr(String,11,1) = '0';&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;datalines;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;SGJ604-01-A&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;AFD345-03-A&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;title "Listing of Test";&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;proc print data=Test;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;run;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;Hope this helps,&lt;/P&gt;&lt;P&gt;Ron&lt;/P&gt;</description>
      <pubDate>Wed, 18 Aug 2021 15:15:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/change-the-last-digit-alphabet-A-to-the-number-0/m-p/762307#M241338</guid>
      <dc:creator>Ron_Cody</dc:creator>
      <dc:date>2021-08-18T15:15:09Z</dc:date>
    </item>
    <item>
      <title>Re: change the last digit alphabet A to the number 0</title>
      <link>https://communities.sas.com/t5/SAS-Programming/change-the-last-digit-alphabet-A-to-the-number-0/m-p/762333#M241354</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/56484"&gt;@Ron_Cody&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Here is a really interesting solution that uses the SUBSTR function on the LEFT side of the = sign.&amp;nbsp; I assume you mean the digit 0 (character) for the last position.&amp;nbsp; Here it is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;data Test;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;length String $ 11;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;input String;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;substr(String,11,1) = '0';&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;datalines;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;SGJ604-01-A&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;AFD345-03-A&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;title "Listing of Test";&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;proc print data=Test;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;run;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Hope this helps,&lt;/P&gt;
&lt;P&gt;Ron&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That unconditionally changes the character to 0. OP only wants the last character to change when it is 'A'&lt;/P&gt;</description>
      <pubDate>Wed, 18 Aug 2021 16:28:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/change-the-last-digit-alphabet-A-to-the-number-0/m-p/762333#M241354</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-08-18T16:28:02Z</dc:date>
    </item>
    <item>
      <title>Re: change the last digit alphabet A to the number 0</title>
      <link>https://communities.sas.com/t5/SAS-Programming/change-the-last-digit-alphabet-A-to-the-number-0/m-p/762519#M241451</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Test;
length String $ 11;
input String;
datalines;
SGJ604-01-A
AFD345-03-A
;
data want;
 set test;
 want=prxchange('s/a$/0/i',1,strip(string));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 Aug 2021 13:06:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/change-the-last-digit-alphabet-A-to-the-number-0/m-p/762519#M241451</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-08-19T13:06:50Z</dc:date>
    </item>
    <item>
      <title>Re: change the last digit alphabet A to the number 0</title>
      <link>https://communities.sas.com/t5/SAS-Programming/change-the-last-digit-alphabet-A-to-the-number-0/m-p/762559#M241459</link>
      <description>&lt;P&gt;Hi.&amp;nbsp; I didn't notice the specification that the last character in the string had to be 'A', so I modified my solution:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;data Test;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;length String $ 11;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;input String;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;if findc(String,'A',lengthn(String)-1) then substr(String,11,1) = '0';&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;datalines;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;SGJ604-01-A&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;XXX999-090B&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;AFD345-03-A&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;title "Listing of Test";&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;proc print data=Test;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;run;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;The last argument in the FINDC function is a starting position.&amp;nbsp; The LENGTHN function is the same as the older LENGTH function--it returns the length of a string, not counting trailing blanks.&amp;nbsp; The 'N' version returns a 0 when the first argument is a missing value; the non 'N' (older function) returns a 1 in this situation.&amp;nbsp; I recommend always using LENGTHN.&amp;nbsp; Hope this helps and clarifies.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Aug 2021 14:50:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/change-the-last-digit-alphabet-A-to-the-number-0/m-p/762559#M241459</guid>
      <dc:creator>Ron_Cody</dc:creator>
      <dc:date>2021-08-19T14:50:32Z</dc:date>
    </item>
  </channel>
</rss>

