<?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 Extract text between 2 text (&amp;quot;:&amp;quot; and &amp;quot;-&amp;quot;) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Extract-text-between-2-text-quot-quot-and-quot-quot/m-p/415330#M280122</link>
    <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to extract text in between 2 character ":" and "-"&amp;nbsp;&lt;/P&gt;
&lt;P&gt;as below:&lt;/P&gt;
&lt;P&gt;For "82 &lt;FONT color="#FF00FF"&gt;&lt;STRONG&gt;:&lt;/STRONG&gt;&lt;/FONT&gt; &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;B2310&lt;/STRONG&gt; &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#FF00FF"&gt;-&lt;/FONT&gt;&lt;/STRONG&gt; I&amp;amp;g9ST LOE, - Project /Task Lead-"&amp;nbsp; the new variable will be&amp;nbsp;&lt;SPAN&gt;B2310&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;The could be multiple "-" but only the first "-" matter.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The output file should be below:&lt;/P&gt;
&lt;P&gt;B2310&lt;BR /&gt;B2310&lt;BR /&gt;B2330&lt;BR /&gt;B2350&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HC&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set test;
    where_colon=find(answer,':');
    where_hyphen=find(answer,'-');

    desired_output1= strip(substr(answer,where_colon+1,where_colon+4));
    desired_output2= strip(substr(answer,where_colon+1,where_hyphen-where_colon-1));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA test;
  INFILE DATALINES DELIMITER=',' DSD;
  INPUT answer &amp;amp; $50.;
  DATALINES;
"82 : B2310 - I&amp;amp;g9ST LOE, Project /Task Lead-"
"83 : B2310 - I&amp;amp;fgST LOE, Quality /IV&amp;amp;V Manager-"
"84 : B2330 - I&amp;amp;fgST LOE,  Expert 2-"
"85 : B2350 - I&amp;amp;ST LOE,  Expert 3-"
;
  RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 21 Nov 2017 22:56:32 GMT</pubDate>
    <dc:creator>hhchenfx</dc:creator>
    <dc:date>2017-11-21T22:56:32Z</dc:date>
    <item>
      <title>Extract text between 2 text (":" and "-")</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-text-between-2-text-quot-quot-and-quot-quot/m-p/415330#M280122</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to extract text in between 2 character ":" and "-"&amp;nbsp;&lt;/P&gt;
&lt;P&gt;as below:&lt;/P&gt;
&lt;P&gt;For "82 &lt;FONT color="#FF00FF"&gt;&lt;STRONG&gt;:&lt;/STRONG&gt;&lt;/FONT&gt; &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;B2310&lt;/STRONG&gt; &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#FF00FF"&gt;-&lt;/FONT&gt;&lt;/STRONG&gt; I&amp;amp;g9ST LOE, - Project /Task Lead-"&amp;nbsp; the new variable will be&amp;nbsp;&lt;SPAN&gt;B2310&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;The could be multiple "-" but only the first "-" matter.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The output file should be below:&lt;/P&gt;
&lt;P&gt;B2310&lt;BR /&gt;B2310&lt;BR /&gt;B2330&lt;BR /&gt;B2350&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HC&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set test;
    where_colon=find(answer,':');
    where_hyphen=find(answer,'-');

    desired_output1= strip(substr(answer,where_colon+1,where_colon+4));
    desired_output2= strip(substr(answer,where_colon+1,where_hyphen-where_colon-1));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA test;
  INFILE DATALINES DELIMITER=',' DSD;
  INPUT answer &amp;amp; $50.;
  DATALINES;
"82 : B2310 - I&amp;amp;g9ST LOE, Project /Task Lead-"
"83 : B2310 - I&amp;amp;fgST LOE, Quality /IV&amp;amp;V Manager-"
"84 : B2330 - I&amp;amp;fgST LOE,  Expert 2-"
"85 : B2350 - I&amp;amp;ST LOE,  Expert 3-"
;
  RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Nov 2017 22:56:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-text-between-2-text-quot-quot-and-quot-quot/m-p/415330#M280122</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2017-11-21T22:56:32Z</dc:date>
    </item>
    <item>
      <title>Re: Extract text between 2 text (":" and "-")</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-text-between-2-text-quot-quot-and-quot-quot/m-p/415331#M280123</link>
      <description>&lt;P&gt;UNTESTED CODE&lt;/P&gt;
&lt;PRE&gt;data want;
    set test;
    where_colon=find(answer,':');
    where_hyphen=find(answer,'-');
    desired_output= strip(substr(answer,where_colon+1,where_hypen-where_colon));
run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 Nov 2017 22:46:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-text-between-2-text-quot-quot-and-quot-quot/m-p/415331#M280123</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-11-21T22:46:06Z</dc:date>
    </item>
    <item>
      <title>Re: Extract text between 2 text (":" and "-")</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-text-between-2-text-quot-quot-and-quot-quot/m-p/415332#M280124</link>
      <description>&lt;P&gt;Use the SCAN() function and the third parameter allows you to set multiple custom delimiters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  want = scan(answer, 2, ":-");&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 Nov 2017 22:48:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-text-between-2-text-quot-quot-and-quot-quot/m-p/415332#M280124</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-11-21T22:48:38Z</dc:date>
    </item>
    <item>
      <title>Re: Extract text between 2 text (":" and "-")</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-text-between-2-text-quot-quot-and-quot-quot/m-p/415334#M280125</link>
      <description>&lt;P&gt;Thanks a lot!!!&lt;/P&gt;
&lt;P&gt;HC&lt;/P&gt;</description>
      <pubDate>Tue, 21 Nov 2017 22:56:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-text-between-2-text-quot-quot-and-quot-quot/m-p/415334#M280125</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2017-11-21T22:56:50Z</dc:date>
    </item>
    <item>
      <title>Re: Extract text between 2 text (":" and "-")</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-text-between-2-text-quot-quot-and-quot-quot/m-p/415353#M280126</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Use the SCAN() function and the third parameter allows you to set multiple custom delimiters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  want = scan(answer, 2, ":-");&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I like it. Easier than my solution.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Nov 2017 01:39:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-text-between-2-text-quot-quot-and-quot-quot/m-p/415353#M280126</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-11-22T01:39:17Z</dc:date>
    </item>
  </channel>
</rss>

