<?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 content between pipes in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Extract-content-between-pipes/m-p/447458#M112413</link>
    <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;I have a data element having values between multiples pipes. I want to extract the value contained between 7th and 8th pipe of each record.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
id=101; report="|1||S17-13284|11529-5|||20170602|||54295|"; output;
id=102; report="|1||S17-13285|11529-5|ABC||20170603|||54296|"; output;
id=103; report="CDE|1||S17-13286|11529-5|||20170604|||54297|"; output;
run;

data want;
id=101; report_date="20170602"; output;
id=102; report_date="20170603"; output;
id=103; report_date="20170604"; output;
run;

/*sascode tried*/
data got ;
 set have;
 length report report_date $50;
 report_date=scan(report,7,"|");
run;

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thank you in advance for your kind reply.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With regards,&lt;/P&gt;</description>
    <pubDate>Wed, 21 Mar 2018 15:55:14 GMT</pubDate>
    <dc:creator>DeepakSwain</dc:creator>
    <dc:date>2018-03-21T15:55:14Z</dc:date>
    <item>
      <title>Extract content between pipes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-content-between-pipes/m-p/447458#M112413</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;I have a data element having values between multiples pipes. I want to extract the value contained between 7th and 8th pipe of each record.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
id=101; report="|1||S17-13284|11529-5|||20170602|||54295|"; output;
id=102; report="|1||S17-13285|11529-5|ABC||20170603|||54296|"; output;
id=103; report="CDE|1||S17-13286|11529-5|||20170604|||54297|"; output;
run;

data want;
id=101; report_date="20170602"; output;
id=102; report_date="20170603"; output;
id=103; report_date="20170604"; output;
run;

/*sascode tried*/
data got ;
 set have;
 length report report_date $50;
 report_date=scan(report,7,"|");
run;

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thank you in advance for your kind reply.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With regards,&lt;/P&gt;</description>
      <pubDate>Wed, 21 Mar 2018 15:55:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-content-between-pipes/m-p/447458#M112413</guid>
      <dc:creator>DeepakSwain</dc:creator>
      <dc:date>2018-03-21T15:55:14Z</dc:date>
    </item>
    <item>
      <title>Re: Extract content between pipes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-content-between-pipes/m-p/447469#M112419</link>
      <description>&lt;P&gt;Use the m modifier in SCAN:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="xis-value"&gt;m or M&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;specifies that multiple consecutive delimiters, and delimiters at the beginning or end of the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="xis-userSuppliedValue"&gt;string&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;argument, refer to words that have a length of zero. &lt;STRONG&gt;If the M modifier is not specified, then multiple consecutive delimiters are treated as one delimiter, and delimiters at the beginning or end of the&amp;nbsp;&lt;SPAN class="xis-userSuppliedValue"&gt;string&lt;/SPAN&gt;&amp;nbsp;argument are ignored.&lt;/STRONG&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data got ;
 set have;
 array check (20) $30.;
 x=countc(report, '|');
 do i=1 to x;
 check(i)=scan(report,i,"|", 'm');
 end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 21 Mar 2018 16:11:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-content-between-pipes/m-p/447469#M112419</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-03-21T16:11:44Z</dc:date>
    </item>
    <item>
      <title>Re: Extract content between pipes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-content-between-pipes/m-p/447487#M112428</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I know this is marked as solved, but here is an alternative solution, if you are looking for a particular pattern&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want(keep=id report_date);
set have;
  pos = prxmatch('/\d{8}\|\|\|/',report);
  if (pos) then
  	report_date = substr(report,pos,8);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Ahmed&lt;/P&gt;</description>
      <pubDate>Wed, 21 Mar 2018 16:35:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-content-between-pipes/m-p/447487#M112428</guid>
      <dc:creator>AhmedAl_Attar</dc:creator>
      <dc:date>2018-03-21T16:35:02Z</dc:date>
    </item>
    <item>
      <title>Re: Extract content between pipes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-content-between-pipes/m-p/447546#M112455</link>
      <description>&lt;P&gt;Thanks a lot.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Mar 2018 19:26:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-content-between-pipes/m-p/447546#M112455</guid>
      <dc:creator>DeepakSwain</dc:creator>
      <dc:date>2018-03-21T19:26:29Z</dc:date>
    </item>
  </channel>
</rss>

