<?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: Substr to extract word from last in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Substr-to-extract-word-from-last/m-p/751423#M236546</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292396"&gt;@David_Billa&lt;/a&gt;&amp;nbsp;Below for you to pick and chose&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  length CRE $50;
  input CRE $;
  datalines;
"[NDID]#MIN2"
"[NDID_TST]#MAX2"
"[NDID_PROD]#AVG"
"[NDID_PROD]#XXX"
;

data want;
  set have;
  length word1_l4 $4 word1_l3 word2-word4 $3;
  word1_l4=scan(cre,-2,'#"');
  word1_l3=scan(cre,-2,'#"');
  word2=compress(scan(cre,-2,'#"'),,'d');
  word3=substrn(scan(cre,-2,'#"'),1,3);
  word4=substrn(cre,find(cre,'#')+1,3);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 01 Jul 2021 10:37:00 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2021-07-01T10:37:00Z</dc:date>
    <item>
      <title>Substr to extract word from last</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Substr-to-extract-word-from-last/m-p/751413#M236544</link>
      <description>&lt;P&gt;In the following program I want to extract the word from last.Desired result is &lt;STRONG&gt;MIN, &lt;/STRONG&gt;&lt;STRONG&gt;MAX, AVG&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;I'm looking for two Solutions here. One with using only substr and other with combination of Scan and substr or with any function.&lt;/P&gt;
&lt;P&gt;Any help?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data test;
length CRE $50;
input CRE $;
datalines;
[NDID]#MIN2
[NDID_TST]#MAX2&lt;BR /&gt;[NDID_PROD]#AVG
;
run;&lt;/PRE&gt;</description>
      <pubDate>Thu, 01 Jul 2021 11:57:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Substr-to-extract-word-from-last/m-p/751413#M236544</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2021-07-01T11:57:53Z</dc:date>
    </item>
    <item>
      <title>Re: Substr to extract word from last</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Substr-to-extract-word-from-last/m-p/751420#M236545</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;want = scan(cre,-1,'#');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;To do this with SUBSTR, you'd probably need to use the FIND function, find the location of the # character, and then SUBSTR. SCAN is so much easier.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jul 2021 10:03:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Substr-to-extract-word-from-last/m-p/751420#M236545</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-07-01T10:03:37Z</dc:date>
    </item>
    <item>
      <title>Re: Substr to extract word from last</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Substr-to-extract-word-from-last/m-p/751423#M236546</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292396"&gt;@David_Billa&lt;/a&gt;&amp;nbsp;Below for you to pick and chose&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  length CRE $50;
  input CRE $;
  datalines;
"[NDID]#MIN2"
"[NDID_TST]#MAX2"
"[NDID_PROD]#AVG"
"[NDID_PROD]#XXX"
;

data want;
  set have;
  length word1_l4 $4 word1_l3 word2-word4 $3;
  word1_l4=scan(cre,-2,'#"');
  word1_l3=scan(cre,-2,'#"');
  word2=compress(scan(cre,-2,'#"'),,'d');
  word3=substrn(scan(cre,-2,'#"'),1,3);
  word4=substrn(cre,find(cre,'#')+1,3);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 01 Jul 2021 10:37:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Substr-to-extract-word-from-last/m-p/751423#M236546</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-07-01T10:37:00Z</dc:date>
    </item>
    <item>
      <title>Re: Substr to extract word from last</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Substr-to-extract-word-from-last/m-p/751425#M236547</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp; what is the meaning of this Argument &lt;STRONG&gt;'#"'&lt;/STRONG&gt; in your code?&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jul 2021 11:03:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Substr-to-extract-word-from-last/m-p/751425#M236547</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2021-07-01T11:03:25Z</dc:date>
    </item>
    <item>
      <title>Re: Substr to extract word from last</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Substr-to-extract-word-from-last/m-p/751428#M236548</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292396"&gt;@David_Billa&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;In the following program I want to extract the word from last.Desired result is &lt;STRONG&gt;MIN, &lt;/STRONG&gt;&lt;STRONG&gt;MAX, AVG&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;I'm looking for two Solutions here. One with using only substr and other with combination of Scan and substr or with any function.&lt;/P&gt;
&lt;P&gt;Any help?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data test;
length CRE $50;
input CRE $;
datalines;
"[NDID]#MIN2"
"[NDID_TST]#MAX2"&lt;BR /&gt;"[NDID_PROD]#AVG"
;
run;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Looking at the above code, is it truly trying to say that the first and last character of the values of CRE strings are double quotes? Or are the double quotes a mistake, and you really mean&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
length CRE $50;
input CRE $;
datalines;
[NDID]#MIN2
[NDID_TST]#MAX2
[NDID_PROD]#AVG
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 01 Jul 2021 11:26:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Substr-to-extract-word-from-last/m-p/751428#M236548</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-07-01T11:26:42Z</dc:date>
    </item>
    <item>
      <title>Re: Substr to extract word from last</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Substr-to-extract-word-from-last/m-p/751430#M236549</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;sorry, double quotes a&amp;nbsp;mistake, Ignore the double quotes in the provided data.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jul 2021 11:56:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Substr-to-extract-word-from-last/m-p/751430#M236549</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2021-07-01T11:56:21Z</dc:date>
    </item>
    <item>
      <title>Re: Substr to extract word from last</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Substr-to-extract-word-from-last/m-p/751432#M236551</link>
      <description>&lt;P&gt;Assuming you have only one # in the column and extract the info without quotation marks, below code should work out.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA TEST_OUTPUT;&lt;BR /&gt;SET TEST;&lt;/P&gt;&lt;P&gt;DESIREDCOLUMN = COMPRESS(SUBSTR(CRE,INDEX(CRE,"#")+1),"""");&lt;BR /&gt;RUN;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jul 2021 12:17:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Substr-to-extract-word-from-last/m-p/751432#M236551</guid>
      <dc:creator>ern_23</dc:creator>
      <dc:date>2021-07-01T12:17:26Z</dc:date>
    </item>
    <item>
      <title>Re: Substr to extract word from last</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Substr-to-extract-word-from-last/m-p/751433#M236552</link>
      <description>&lt;PRE&gt;data test;
length CRE $50;
input CRE $;
datalines;
[NDID]#MIN2
[NDID_TST]#MAX2
[NDID_PROD]#AVG
;
run;

data want;
  set test;
  want=scan(cre,-1,,'ka');
run;&lt;/PRE&gt;</description>
      <pubDate>Thu, 01 Jul 2021 12:26:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Substr-to-extract-word-from-last/m-p/751433#M236552</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-07-01T12:26:59Z</dc:date>
    </item>
  </channel>
</rss>

