<?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: Extracting zero or more codes from a string in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Extracting-zero-or-more-codes-from-a-string/m-p/298100#M62656</link>
    <description>Works great. Thank you!</description>
    <pubDate>Tue, 13 Sep 2016 17:06:47 GMT</pubDate>
    <dc:creator>brucehughw</dc:creator>
    <dc:date>2016-09-13T17:06:47Z</dc:date>
    <item>
      <title>Extracting zero or more codes from a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-zero-or-more-codes-from-a-string/m-p/298079#M62650</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a field that contains (ideally) a single three-number code, e.g., 123. Variations on this ideal case include:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;missing data&lt;/LI&gt;
&lt;LI&gt;;&lt;/LI&gt;
&lt;LI&gt;123;&lt;/LI&gt;
&lt;LI&gt;123; 123&lt;/LI&gt;
&lt;LI&gt;123 456&lt;/LI&gt;
&lt;LI&gt;123; 456&lt;/LI&gt;
&lt;LI&gt;123; 456;&lt;/LI&gt;
&lt;LI&gt;123; &amp;nbsp;456;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;I think that's about it. Each row (observation) contains other fields. When my code field is empty, I'd like to just ignore that observation. If there's only one code, I'll save (output) the observatoin. If there's two unique codes, I'd like to output&amp;nbsp;the observation twice, once for each code. If the code is a lot trickier for the 123; 123 case, I can live with a duplicate. I was thinking of using some of the prx functions. Any suggestions?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks! Bruce&lt;/P&gt;</description>
      <pubDate>Tue, 13 Sep 2016 15:26:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-zero-or-more-codes-from-a-string/m-p/298079#M62650</guid>
      <dc:creator>brucehughw</dc:creator>
      <dc:date>2016-09-13T15:26:36Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting zero or more codes from a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-zero-or-more-codes-from-a-string/m-p/298088#M62652</link>
      <description>&lt;P&gt;Is this a text file you are reading or is this "field" already a SAS variable?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By "ignore" do you mean remove from the data set?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Scan should work just fine if this is already a SAS varaible.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
   infile datalines truncover;
   input code $ 1-15 ;
datalines4;
 
;
123;
123; 123
123 456
123; 456
123; 456;
123;  456;
;;;;
run;

data want;
   set have;
   if countw(code,' ;,')&amp;gt;0 then do i=1 to (countw(code,' ;,'));
      NewCode=scan(code,i,' ;,');
      output;
   end;
   drop i;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Sep 2016 17:21:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-zero-or-more-codes-from-a-string/m-p/298088#M62652</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-09-13T17:21:53Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting zero or more codes from a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-zero-or-more-codes-from-a-string/m-p/298096#M62655</link>
      <description>Hi. The field is already a SAS variable, one of many variables in a data set. Yes, "ignore" means remove from the data set. I will try your code. Thank you!</description>
      <pubDate>Tue, 13 Sep 2016 16:48:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-zero-or-more-codes-from-a-string/m-p/298096#M62655</guid>
      <dc:creator>brucehughw</dc:creator>
      <dc:date>2016-09-13T16:48:01Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting zero or more codes from a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-zero-or-more-codes-from-a-string/m-p/298100#M62656</link>
      <description>Works great. Thank you!</description>
      <pubDate>Tue, 13 Sep 2016 17:06:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-zero-or-more-codes-from-a-string/m-p/298100#M62656</guid>
      <dc:creator>brucehughw</dc:creator>
      <dc:date>2016-09-13T17:06:47Z</dc:date>
    </item>
  </channel>
</rss>

