<?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: Using a delimiter to parse the string into a new variable but don't want delimiter outputted. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Using-a-delimiter-to-parse-the-string-into-a-new-variable-but/m-p/785414#M250650</link>
    <description>&lt;P&gt;It would be straightforward to use the SCAN function for this job.&amp;nbsp; That's what it was built for, along these lines:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work._ref_mat_info (label = "Reference Materials") ;
   length clause $200 ;
   set test;
   where REFMATS ne " ";
   do _n_=1 to 100 until (clause=' ');
      clause = scan(REFMATS, _n_, '[');
      if clause ne ' ' then output;   
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 10 Dec 2021 15:15:19 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2021-12-10T15:15:19Z</dc:date>
    <item>
      <title>Using a delimiter to parse the string into a new variable but don't want delimiter outputted.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-a-delimiter-to-parse-the-string-into-a-new-variable-but/m-p/785380#M250643</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have this string:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;REFMATS= [&lt;SPAN&gt;Type:ADRG, URL :, Version : , Status : , Date : Notes :,[Type:P21 Report, URL :, Version : , Status : , Date : Notes :,[Type:eSub Source Data Location, URL :, Version : , Status : , Date : Notes :,[Type:eSub Data Package Location, URL :, Version : , Status : , Date : Notes :&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I am using "[" as a delimiter to segment&amp;nbsp;this string into clauses&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;data work._ref_mat_info (label = "Reference Materials") ;&lt;BR /&gt;length clause $200 ;&lt;BR /&gt;set test;&lt;BR /&gt;where REFMATS ne "";&lt;BR /&gt;_i = 0 ;&lt;BR /&gt;do until(REFMATS = "") ;&lt;BR /&gt;_i + 1 ;&lt;BR /&gt;if _i &amp;gt;= 100 then stop ;&lt;BR /&gt;_pos = index(REFMATS,'[');&lt;BR /&gt;if _pos = 0 then do ;&lt;BR /&gt;clause = REFMATS ;&lt;BR /&gt;REFMATS = "" ;&lt;BR /&gt;end ; &lt;BR /&gt;else do ;&lt;BR /&gt;clause = substr(REFMATS,1,_pos);&lt;BR /&gt;REFMATS = substr(REFMATS,sum(_pos,1));&lt;BR /&gt;end ;&lt;BR /&gt;output;&lt;BR /&gt;end ;&lt;BR /&gt;run ; &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, it keeps outputting the first "[" as an individual clause so it is not lining up properly with the REFMATS string on the output dataset. Could you advise how to modify the code to use the delimiter "[" but it doesn't get outputted as an observation so the REFMATS line up properly with the clause.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Dec 2021 13:04:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-a-delimiter-to-parse-the-string-into-a-new-variable-but/m-p/785380#M250643</guid>
      <dc:creator>Dregerator</dc:creator>
      <dc:date>2021-12-10T13:04:20Z</dc:date>
    </item>
    <item>
      <title>Re: Using a delimiter to parse the string into a new variable but don't want delimiter outputted.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-a-delimiter-to-parse-the-string-into-a-new-variable-but/m-p/785414#M250650</link>
      <description>&lt;P&gt;It would be straightforward to use the SCAN function for this job.&amp;nbsp; That's what it was built for, along these lines:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work._ref_mat_info (label = "Reference Materials") ;
   length clause $200 ;
   set test;
   where REFMATS ne " ";
   do _n_=1 to 100 until (clause=' ');
      clause = scan(REFMATS, _n_, '[');
      if clause ne ' ' then output;   
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 10 Dec 2021 15:15:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-a-delimiter-to-parse-the-string-into-a-new-variable-but/m-p/785414#M250650</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2021-12-10T15:15:19Z</dc:date>
    </item>
    <item>
      <title>Re: Using a delimiter to parse the string into a new variable but don't want delimiter outputted.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-a-delimiter-to-parse-the-string-into-a-new-variable-but/m-p/785420#M250653</link>
      <description>&lt;P&gt;If you use Countw(Refmat,'[') can tell exactly how many elements there are to parse.&lt;/P&gt;
&lt;P&gt;If you don't want the "REFMATS=" as a clause start at the second element.&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;data example (label = "Reference Materials") ;
   length clause $200 ;
   refmats="REFMATS= [Type:ADRG, URL :, Version : , Status : , Date : Notes :,[Type:P21 Report, URL :, Version : , Status : , Date : Notes :,[Type:eSub Source Data Location, URL :, Version : , Status : , Date : Notes :,[Type:eSub Data Package Location, URL :, Version : , Status : , Date : Notes :";
   do _n_=2 to countw(refmats,'[');
      clause = scan(REFMATS, _n_, '[');
      if clause ne ' ' then output;   
   end;
run;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Dec 2021 16:06:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-a-delimiter-to-parse-the-string-into-a-new-variable-but/m-p/785420#M250653</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-12-10T16:06:53Z</dc:date>
    </item>
  </channel>
</rss>

