<?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 Capturing the last character in a variable value in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Capturing-the-last-character-in-a-variable-value/m-p/152894#M11997</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This may be a simple question, but I'm quite new to SAS.&amp;nbsp; I'm trying to do a few things, but before I can do any of the substantive stuff, I first need to identify the cases where the values in a variable called LPCT end in a 0 or 5.&amp;nbsp; The values in LPCT differ in length though so I don't know how to specify the position of the last integer in the value.&amp;nbsp;&amp;nbsp; Is there is a command for "last character" or "ends in"&amp;nbsp; in SAS language?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to to this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF LPCT &lt;EM&gt;ends-in&lt;/EM&gt; 0 OR LPCT &lt;EM&gt;ends-in &lt;/EM&gt;THEN ROUNDED=1;&lt;/P&gt;&lt;P&gt;ELSE ROUNDED=0;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but I don't know the real SAS-words for &lt;EM&gt;ends-in.&amp;nbsp; &lt;/EM&gt;Some version of the SUBSTR function would be great too, but again, the values of LPCT are of varyng lengths so I can't specify a numeric position for the integer I want to capture...I need to just tell SAS to take the last number in the variable's value somehow. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm not sure if I'm being clear but I hope someone has some suggestion!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 23 Jun 2014 19:39:21 GMT</pubDate>
    <dc:creator>svetting</dc:creator>
    <dc:date>2014-06-23T19:39:21Z</dc:date>
    <item>
      <title>Capturing the last character in a variable value</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Capturing-the-last-character-in-a-variable-value/m-p/152894#M11997</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This may be a simple question, but I'm quite new to SAS.&amp;nbsp; I'm trying to do a few things, but before I can do any of the substantive stuff, I first need to identify the cases where the values in a variable called LPCT end in a 0 or 5.&amp;nbsp; The values in LPCT differ in length though so I don't know how to specify the position of the last integer in the value.&amp;nbsp;&amp;nbsp; Is there is a command for "last character" or "ends in"&amp;nbsp; in SAS language?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to to this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF LPCT &lt;EM&gt;ends-in&lt;/EM&gt; 0 OR LPCT &lt;EM&gt;ends-in &lt;/EM&gt;THEN ROUNDED=1;&lt;/P&gt;&lt;P&gt;ELSE ROUNDED=0;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but I don't know the real SAS-words for &lt;EM&gt;ends-in.&amp;nbsp; &lt;/EM&gt;Some version of the SUBSTR function would be great too, but again, the values of LPCT are of varyng lengths so I can't specify a numeric position for the integer I want to capture...I need to just tell SAS to take the last number in the variable's value somehow. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm not sure if I'm being clear but I hope someone has some suggestion!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jun 2014 19:39:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Capturing-the-last-character-in-a-variable-value/m-p/152894#M11997</guid>
      <dc:creator>svetting</dc:creator>
      <dc:date>2014-06-23T19:39:21Z</dc:date>
    </item>
    <item>
      <title>Re: Capturing the last character in a variable value</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Capturing-the-last-character-in-a-variable-value/m-p/152895#M11998</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; input lpct;&lt;/P&gt;&lt;P&gt; cards;&lt;/P&gt;&lt;P&gt; 1&lt;/P&gt;&lt;P&gt; 2&lt;/P&gt;&lt;P&gt; 2.5&lt;/P&gt;&lt;P&gt; 30&lt;/P&gt;&lt;P&gt; 8&lt;/P&gt;&lt;P&gt; ;&lt;/P&gt;&lt;P&gt; data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if first(reverse(lpct)) in ('0','5') then rounded=1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; else rounded=0;&lt;/P&gt;&lt;P&gt; proc print;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jun 2014 19:51:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Capturing-the-last-character-in-a-variable-value/m-p/152895#M11998</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2014-06-23T19:51:14Z</dc:date>
    </item>
    <item>
      <title>Re: Capturing the last character in a variable value</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Capturing-the-last-character-in-a-variable-value/m-p/152896#M11999</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New';"&gt; y1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: blue; font-family: 'Courier New';"&gt;input&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New';"&gt; id LPCT $;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: blue; font-family: 'Courier New';"&gt;cards&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New';"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: #ffffc0; color: black; font-family: 'Courier New';"&gt;1 sam0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: #ffffc0; color: black; font-family: 'Courier New';"&gt;2 alex5&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: #ffffc0; color: black; font-family: 'Courier New';"&gt;3 jason0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New';"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New';"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New';"&gt; y2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN style="background: white; color: blue; font-family: 'Courier New';"&gt;set&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New';"&gt; y1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New';"&gt;required_output=substr(lpct,length(lpct),&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New';"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New';"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New';"&gt;Hope this helps !!&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jun 2014 20:08:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Capturing-the-last-character-in-a-variable-value/m-p/152896#M11999</guid>
      <dc:creator>yeshwanth</dc:creator>
      <dc:date>2014-06-23T20:08:28Z</dc:date>
    </item>
    <item>
      <title>Re: Capturing the last character in a variable value</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Capturing-the-last-character-in-a-variable-value/m-p/152897#M12000</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The more, the merrier:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; y1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; id LPCT $;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;cards&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;1 sam0&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;2 alex5&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;3 jason1&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;DATA&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; WANT;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;SET&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; Y1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ROUND=PRXMATCH(&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: purple; background: white;"&gt;'/[5|0]$/'&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;,strip(lpct))&amp;gt;&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-family: 'Courier New';"&gt;0&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jun 2014 20:48:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Capturing-the-last-character-in-a-variable-value/m-p/152897#M12000</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2014-06-23T20:48:01Z</dc:date>
    </item>
    <item>
      <title>Re: Capturing the last character in a variable value</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Capturing-the-last-character-in-a-variable-value/m-p/152898#M12001</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK, then it's quiz time.&amp;nbsp; Why does this attempt give the wrong answer?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;round = reverse(lpct) in : ('0', '5');&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jun 2014 21:01:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Capturing-the-last-character-in-a-variable-value/m-p/152898#M12001</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2014-06-23T21:01:22Z</dc:date>
    </item>
    <item>
      <title>Re: Capturing the last character in a variable value</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Capturing-the-last-character-in-a-variable-value/m-p/152899#M12002</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;All solutions proposed so far have small weaknesses ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A __default_attr="3068" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt; With REVERSE, trailing spaces will become leading spaces, so you would want to TRIM first.&lt;/P&gt;&lt;P&gt;&lt;A __default_attr="807178" __jive_macro_name="user" class="jive_macro jive_macro_user" href="https://communities.sas.com/" modifiedtitle="true" title="yeshwanth"&gt;&lt;/A&gt; You would still need to compare the resulting string with "0" and "5"&lt;/P&gt;&lt;P&gt;&lt;A __default_attr="5068" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt; The pipe character is not required in the pattern&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data y1;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; input id lpct $;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;datalines;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;1 sam0&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;2 alex5&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;3 jason1&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;DATA WANT;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SET Y1;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ROUNDED = CHAR(lpct, LENGTH(lpct)) in ("0", "5");&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jun 2014 21:52:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Capturing-the-last-character-in-a-variable-value/m-p/152899#M12002</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2014-06-23T21:52:34Z</dc:date>
    </item>
    <item>
      <title>Re: Capturing the last character in a variable value</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Capturing-the-last-character-in-a-variable-value/m-p/152900#M12003</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;:smileylaugh:&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jun 2014 23:10:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Capturing-the-last-character-in-a-variable-value/m-p/152900#M12003</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2014-06-23T23:10:58Z</dc:date>
    </item>
    <item>
      <title>Re: Capturing the last character in a variable value</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Capturing-the-last-character-in-a-variable-value/m-p/152901#M12004</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If I guess right. lpct after reversing ,it should be starting with BLANK .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Jun 2014 14:21:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Capturing-the-last-character-in-a-variable-value/m-p/152901#M12004</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2014-06-24T14:21:18Z</dc:date>
    </item>
    <item>
      <title>Re: Capturing the last character in a variable value</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Capturing-the-last-character-in-a-variable-value/m-p/152902#M12005</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, that's the issue.&amp;nbsp; I wasn't sure anyone would answer on this, since PG Stats hinted at the problem with his comment about Linlin's solution.&amp;nbsp; When reversing generates a leading blank, both my quiz and Linlin's solution face this issue.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Jun 2014 15:24:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Capturing-the-last-character-in-a-variable-value/m-p/152902#M12005</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2014-06-24T15:24:08Z</dc:date>
    </item>
  </channel>
</rss>

