<?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: Field Separation into multiple fields in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Field-Separation-into-multiple-fields/m-p/616362#M180430</link>
    <description>&lt;P&gt;Let me clarify...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For the first question, let's assume that the record shows |38|15|. I would like a new field to be created called "Num_Issues" that should show a value of 2. Let's assume that the next record shows |15|3|5|8|. I would like the field "Num_Issues" to show a value of 4.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For the second question, lets assume the current field shows |38|15|. I want to create a field called "Issue_38" that is a "1" if 38 is found within the string, and "0" if 38 is not found within the string.&lt;/P&gt;</description>
    <pubDate>Fri, 10 Jan 2020 01:18:21 GMT</pubDate>
    <dc:creator>anweinbe</dc:creator>
    <dc:date>2020-01-10T01:18:21Z</dc:date>
    <item>
      <title>Field Separation into multiple fields</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Field-Separation-into-multiple-fields/m-p/616356#M180425</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV style="font-family: Calibri,Arial,Helvetica,sans-serif; font-size: 12pt; color: #000000;"&gt;I have a file that has a column called "issue" that includes several numerical codes for issues identified from testing. For example, the entry in the field might be "|38|15|" indicating that issues 38 and 15 were identified. How do I separate this field out into multiple columns so "38" is in one column and "15" is in another? I would also like to remove the "|"s. &lt;/DIV&gt;
&lt;DIV style="font-family: Calibri,Arial,Helvetica,sans-serif; font-size: 12pt; color: #000000;"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV style="font-family: Calibri,Arial,Helvetica,sans-serif; font-size: 12pt; color: #000000;"&gt;Some fields have no issue codes, some can have up to 5!&lt;/DIV&gt;
&lt;DIV style="font-family: Calibri,Arial,Helvetica,sans-serif; font-size: 12pt; color: #000000;"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV style="font-family: Calibri,Arial,Helvetica,sans-serif; font-size: 12pt; color: #000000;"&gt;Thank you for your insights!&lt;/DIV&gt;</description>
      <pubDate>Fri, 10 Jan 2020 00:22:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Field-Separation-into-multiple-fields/m-p/616356#M180425</guid>
      <dc:creator>anweinbe</dc:creator>
      <dc:date>2020-01-10T00:22:23Z</dc:date>
    </item>
    <item>
      <title>Re: Field Separation into multiple fields</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Field-Separation-into-multiple-fields/m-p/616359#M180427</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/287480"&gt;@anweinbe&lt;/a&gt;&amp;nbsp; Do you mean this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
num_code="|38|15|" ;
run;

data want;
set have;
array want(5)$;
do _n_=1 to countw(num_code,'|');
 want(_n_)=scan(num_code,_n_,'|');
end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If not, please provide data samples of HAVE and WANT. Thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jan 2020 00:36:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Field-Separation-into-multiple-fields/m-p/616359#M180427</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-01-10T00:36:17Z</dc:date>
    </item>
    <item>
      <title>Re: Field Separation into multiple fields</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Field-Separation-into-multiple-fields/m-p/616360#M180428</link>
      <description>&lt;P&gt;This appeared to work...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I do have a few more question if you don't mind.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Is there an easy way to create a field that tells me how many error codes I have? So in the example I gave the field would report "2". If there code was |15|23|23| it would report "3" etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. What syntax would I need for an If statement to search for a particular code? I was thinking something like this...however what do I put in place of the word "contains"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If field contains |15| then Issue_1 = 0;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jan 2020 00:58:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Field-Separation-into-multiple-fields/m-p/616360#M180428</guid>
      <dc:creator>anweinbe</dc:creator>
      <dc:date>2020-01-10T00:58:05Z</dc:date>
    </item>
    <item>
      <title>Re: Field Separation into multiple fields</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Field-Separation-into-multiple-fields/m-p/616361#M180429</link>
      <description>&lt;P&gt;HI&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/287480"&gt;@anweinbe&lt;/a&gt;&amp;nbsp; The modified code below should suffice for some with issue or none, and the num of error&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
num_code="|38|15|" ;
output;
call missing(num_code);
output;
run;

data want;
set have;
array want(5)$;
num_of_error=countw(num_code,'|','t');
if num_of_error then
do _n_=1 to num_of_error;
 want(_n_)=scan(num_code,_n_,'|');
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;for 2. You need to explain/show how your output should look like. Your words and sentences is making me assume things. plz&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jan 2020 01:08:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Field-Separation-into-multiple-fields/m-p/616361#M180429</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-01-10T01:08:41Z</dc:date>
    </item>
    <item>
      <title>Re: Field Separation into multiple fields</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Field-Separation-into-multiple-fields/m-p/616362#M180430</link>
      <description>&lt;P&gt;Let me clarify...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For the first question, let's assume that the record shows |38|15|. I would like a new field to be created called "Num_Issues" that should show a value of 2. Let's assume that the next record shows |15|3|5|8|. I would like the field "Num_Issues" to show a value of 4.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For the second question, lets assume the current field shows |38|15|. I want to create a field called "Issue_38" that is a "1" if 38 is found within the string, and "0" if 38 is not found within the string.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jan 2020 01:18:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Field-Separation-into-multiple-fields/m-p/616362#M180430</guid>
      <dc:creator>anweinbe</dc:creator>
      <dc:date>2020-01-10T01:18:21Z</dc:date>
    </item>
    <item>
      <title>Re: Field Separation into multiple fields</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Field-Separation-into-multiple-fields/m-p/616363#M180431</link>
      <description>&lt;P&gt;I apologize, the code you send for the first question did work! I forgot to rename one of the fields...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just the 2nd question is left!&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jan 2020 01:22:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Field-Separation-into-multiple-fields/m-p/616363#M180431</guid>
      <dc:creator>anweinbe</dc:creator>
      <dc:date>2020-01-10T01:22:31Z</dc:date>
    </item>
    <item>
      <title>Re: Field Separation into multiple fields</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Field-Separation-into-multiple-fields/m-p/616367#M180432</link>
      <description>I figured out the last part. I needed to use "findw()"</description>
      <pubDate>Fri, 10 Jan 2020 01:51:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Field-Separation-into-multiple-fields/m-p/616367#M180432</guid>
      <dc:creator>anweinbe</dc:creator>
      <dc:date>2020-01-10T01:51:14Z</dc:date>
    </item>
  </channel>
</rss>

