<?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: Manipulating the first character in a string in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Manipulating-the-first-character-in-a-string/m-p/125789#M1602</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; input&amp;nbsp; CUST_NO $;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; firstchar=put(input(substr(CUST_NO,1,1),8.)-3,1.)||strip(substr(CUST_NO,2));&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;4512648&lt;/P&gt;&lt;P&gt;5487512&lt;/P&gt;&lt;P&gt;6123658&lt;/P&gt;&lt;P&gt;6548756&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Jagadish&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 28 Oct 2013 10:21:18 GMT</pubDate>
    <dc:creator>Jagadishkatam</dc:creator>
    <dc:date>2013-10-28T10:21:18Z</dc:date>
    <item>
      <title>Manipulating the first character in a string</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Manipulating-the-first-character-in-a-string/m-p/125788#M1601</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have an input table with a character column called "CUST_NO". It includes values such as these:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"4512648"&lt;/P&gt;&lt;P&gt;"5487512"&lt;/P&gt;&lt;P&gt;"6123658"&lt;/P&gt;&lt;P&gt;"6548756"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The first character will always be 4, 5, or 6.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I want to do is to reduce the the first character of each by 3. So the output should be like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"1512648"&lt;/P&gt;&lt;P&gt;"2487512"&lt;/P&gt;&lt;P&gt;"3123658"&lt;/P&gt;&lt;P&gt;"3548756"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I figure I might use an expression which starts this way:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;firstchar = substr(CUST_NO,1,1)&lt;/P&gt;&lt;P&gt;case&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; when firstchar = "4" then firstchar = "1"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; when firstchar = "5" then firstchar = "2"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; when firstchar = "6" then firstchar = "3"&lt;/P&gt;&lt;P&gt;end&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, I can't think of an elegant way to proceed after this. Can you please advise me?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Oct 2013 10:06:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Manipulating-the-first-character-in-a-string/m-p/125788#M1601</guid>
      <dc:creator>EinarRoed</dc:creator>
      <dc:date>2013-10-28T10:06:05Z</dc:date>
    </item>
    <item>
      <title>Re: Manipulating the first character in a string</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Manipulating-the-first-character-in-a-string/m-p/125789#M1602</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; input&amp;nbsp; CUST_NO $;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; firstchar=put(input(substr(CUST_NO,1,1),8.)-3,1.)||strip(substr(CUST_NO,2));&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;4512648&lt;/P&gt;&lt;P&gt;5487512&lt;/P&gt;&lt;P&gt;6123658&lt;/P&gt;&lt;P&gt;6548756&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Jagadish&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Oct 2013 10:21:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Manipulating-the-first-character-in-a-string/m-p/125789#M1602</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2013-10-28T10:21:18Z</dc:date>
    </item>
    <item>
      <title>Re: Manipulating the first character in a string</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Manipulating-the-first-character-in-a-string/m-p/125790#M1603</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, you're a top-quality Jagadish. &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Oct 2013 10:31:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Manipulating-the-first-character-in-a-string/m-p/125790#M1603</guid>
      <dc:creator>EinarRoed</dc:creator>
      <dc:date>2013-10-28T10:31:25Z</dc:date>
    </item>
    <item>
      <title>Re: Manipulating the first character in a string</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Manipulating-the-first-character-in-a-string/m-p/125791#M1604</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Alternatively you could translate the character digits and use substr on the left side of =.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;DIV style="font-family: Courier New; font-size: 11pt;"&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;data&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; first;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; x :&lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;$quote16.&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; substr(x,&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;1&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;,&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;1&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;)=translate(first(x),&lt;/SPAN&gt;&lt;SPAN style="color: #800080; background-color: #ffffff;"&gt;'123'&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #800080; background-color: #ffffff;"&gt;'456'&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;);&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;cards&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffc0;"&gt;"4512648"&lt;BR /&gt;"5487512"&lt;BR /&gt;"6123658"&lt;BR /&gt;"6548756"&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;;;;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;run&lt;/STRONG&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;print&lt;/STRONG&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;run&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Oct 2013 10:46:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Manipulating-the-first-character-in-a-string/m-p/125791#M1604</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2013-10-28T10:46:18Z</dc:date>
    </item>
  </channel>
</rss>

