<?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 do i extract value from these possible value from a column? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-extract-value-from-these-possible-value-from-a-column/m-p/545154#M150781</link>
    <description>&lt;P&gt;Posting data in usable form helps us to help you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i would use a regular expression: "/(.*\/)?(.+)/" and the function prxposn to get the second capture group.&lt;/P&gt;</description>
    <pubDate>Fri, 22 Mar 2019 08:50:51 GMT</pubDate>
    <dc:creator>andreas_lds</dc:creator>
    <dc:date>2019-03-22T08:50:51Z</dc:date>
    <item>
      <title>How do i extract value from these possible value from a column?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-extract-value-from-these-possible-value-from-a-column/m-p/545152#M150780</link>
      <description>&lt;P&gt;Hi everyone. I have a column that contains below possible value&lt;/P&gt;&lt;P&gt;132/11&lt;/P&gt;&lt;P&gt;132/33&lt;/P&gt;&lt;P&gt;33/11&lt;/P&gt;&lt;P&gt;11/&lt;/P&gt;&lt;P&gt;33/&lt;/P&gt;&lt;P&gt;33&lt;/P&gt;&lt;P&gt;11&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to do the following&lt;/P&gt;&lt;P&gt;if whatever behind / is not blank, take the value after /&lt;/P&gt;&lt;P&gt;If value after / is blank, take the front&lt;/P&gt;&lt;P&gt;if no /, take whatever it has.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried substr(colA,1,length(colA)-1) and it wont work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone help me on this?&lt;/P&gt;</description>
      <pubDate>Fri, 22 Mar 2019 08:33:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-extract-value-from-these-possible-value-from-a-column/m-p/545152#M150780</guid>
      <dc:creator>imdickson</dc:creator>
      <dc:date>2019-03-22T08:33:22Z</dc:date>
    </item>
    <item>
      <title>Re: How do i extract value from these possible value from a column?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-extract-value-from-these-possible-value-from-a-column/m-p/545154#M150781</link>
      <description>&lt;P&gt;Posting data in usable form helps us to help you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i would use a regular expression: "/(.*\/)?(.+)/" and the function prxposn to get the second capture group.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Mar 2019 08:50:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-extract-value-from-these-possible-value-from-a-column/m-p/545154#M150781</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2019-03-22T08:50:51Z</dc:date>
    </item>
    <item>
      <title>Re: How do i extract value from these possible value from a column?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-extract-value-from-these-possible-value-from-a-column/m-p/545155#M150782</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15475"&gt;@andreas_lds&lt;/a&gt;That looks very nearly perfect. I would suggest the expression "/(.*\/)?([0-9]+)/" instead to avoid capturing the end slash if there is no data&amp;nbsp; after the slash (capture 11 instead of 11/).&lt;/P&gt;&lt;P&gt;132/&lt;STRONG&gt;11&lt;/STRONG&gt;&lt;BR /&gt;132/&lt;STRONG&gt;33&lt;/STRONG&gt;&lt;BR /&gt;33/&lt;STRONG&gt;11&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;11&lt;/STRONG&gt;/&lt;BR /&gt;&lt;STRONG&gt;33&lt;/STRONG&gt;/&lt;BR /&gt;&lt;STRONG&gt;33&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;11&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/63520"&gt;@imdickson&lt;/a&gt;I would suggest a website like&amp;nbsp;&lt;A href="https://regex101.com/" target="_self"&gt;https://regex101.com/ &lt;/A&gt;to test and learn regular expressions.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Mar 2019 09:15:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-extract-value-from-these-possible-value-from-a-column/m-p/545155#M150782</guid>
      <dc:creator>DanielLangley</dc:creator>
      <dc:date>2019-03-22T09:15:21Z</dc:date>
    </item>
    <item>
      <title>Re: How do i extract value from these possible value from a column?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-extract-value-from-these-possible-value-from-a-column/m-p/545160#M150783</link>
      <description>&lt;P&gt;Alternatively use next code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ix = index(var,'/');

if ix &amp;gt; 0 and ix &amp;lt; length(trim(var)) 
    then new_var = substr(var,ix+1);
    else new_var=compress(var,'/');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Mar 2019 09:36:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-extract-value-from-these-possible-value-from-a-column/m-p/545160#M150783</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2019-03-22T09:36:35Z</dc:date>
    </item>
    <item>
      <title>Re: How do i extract value from these possible value from a column?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-extract-value-from-these-possible-value-from-a-column/m-p/545161#M150784</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/63520"&gt;@imdickson&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The combination of &lt;A href="https://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=p1g9btrql8d9x6n1iz6yowaqrq1v.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank" rel="noopener"&gt;COALESCEC&lt;/A&gt; and &lt;A href="https://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=p0jshdjy2z9zdzn1h7k90u99lyq6.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank" rel="noopener"&gt;SCAN&lt;/A&gt;&amp;nbsp;functions can do this as well:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input h $;
cards;
132/11
132/33
33/11
11/
33/
33
11
;

data want;
set have;
length w $8;
w=coalescec(scan(h,2,'/'),scan(h,1,'/'));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Mar 2019 09:38:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-extract-value-from-these-possible-value-from-a-column/m-p/545161#M150784</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2019-03-22T09:38:37Z</dc:date>
    </item>
    <item>
      <title>Re: How do i extract value from these possible value from a column?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-extract-value-from-these-possible-value-from-a-column/m-p/545165#M150786</link>
      <description>&lt;P&gt;Using the "standard" string handling functions:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input h $;
cards;
132/11
132/33
33/11
11/
33/
33
11
;
run;

data want;
set have;
if countw(h,'/') &amp;lt;= 1
then w = h;
else do;
  w = scan(h,2,'/');
  if w = ' ' then w = scan(h,1,'/');
end;
run;

proc print data=want noobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;h         w

132/11    11
132/33    33
33/11     11
11/       11
33/       33
33        33
11        11
&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Mar 2019 09:54:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-extract-value-from-these-possible-value-from-a-column/m-p/545165#M150786</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-03-22T09:54:22Z</dc:date>
    </item>
    <item>
      <title>Re: How do i extract value from these possible value from a column?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-extract-value-from-these-possible-value-from-a-column/m-p/545166#M150787</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt; : Nice!&lt;/P&gt;</description>
      <pubDate>Fri, 22 Mar 2019 09:55:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-extract-value-from-these-possible-value-from-a-column/m-p/545166#M150787</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-03-22T09:55:21Z</dc:date>
    </item>
    <item>
      <title>Re: How do i extract value from these possible value from a column?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-extract-value-from-these-possible-value-from-a-column/m-p/545182#M150789</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input h $;
cards;
132/11
132/33
33/11
11/
33/
33
11
;
run;
data want;
 set have;
 want=scan(h,-1,'/ ');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Mar 2019 11:09:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-extract-value-from-these-possible-value-from-a-column/m-p/545182#M150789</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-03-22T11:09:30Z</dc:date>
    </item>
    <item>
      <title>Re: How do i extract value from these possible value from a column?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-extract-value-from-these-possible-value-from-a-column/m-p/545219#M150800</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;: Elegant! (As long as no embedded blanks break it.)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input h $12.;
cards;
132/break it
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Mar 2019 13:40:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-extract-value-from-these-possible-value-from-a-column/m-p/545219#M150800</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2019-03-22T13:40:42Z</dc:date>
    </item>
  </channel>
</rss>

