<?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: How can I split two numbers from the same column in SAS EG 7.1? in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-can-I-split-two-numbers-from-the-same-column-in-SAS-EG-7-1/m-p/514011#M2622</link>
    <description>COUNTW() to count the number of items&lt;BR /&gt;SCAN() to split. &lt;BR /&gt;temp = smi_error_code;&lt;BR /&gt;do i=1 to countw(temp, '|');&lt;BR /&gt;smi_error_code = scan(temp, i, '|');&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;</description>
    <pubDate>Fri, 16 Nov 2018 18:11:45 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-11-16T18:11:45Z</dc:date>
    <item>
      <title>How can I split two numbers from the same column in SAS EG 7.1?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-can-I-split-two-numbers-from-the-same-column-in-SAS-EG-7-1/m-p/514008#M2621</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a data set where I have two codes in the same column:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SAS.PNG" style="width: 560px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/25008i560584512BB5B0EA/image-size/large?v=v2&amp;amp;px=999" role="button" title="SAS.PNG" alt="SAS.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to split the two codes in two distinct lines, having into acount that the other attributes don't change. For example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;SRV_ERROR_CODE&amp;nbsp; DESC_ERRO_SERVIC&amp;nbsp; SMI_ERROR_CODE&amp;nbsp; ERROR_CODE_SMI&amp;nbsp; SMI_STATE&amp;nbsp; &amp;nbsp;SRV&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;50070&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Subprocesso O...&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 30089&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 30089&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; PRBL&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;TER&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;50070&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Subprocesso O...&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 30089&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 30089&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; PRBL&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;TER&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Is there any SAS function that doses this?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Sometimes I have two codes to split, sometimes 3 codes, sometimes 4... I don't have any exact rule...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Rita Viegas&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Nov 2018 18:05:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-can-I-split-two-numbers-from-the-same-column-in-SAS-EG-7-1/m-p/514008#M2621</guid>
      <dc:creator>Rita_Viegas</dc:creator>
      <dc:date>2018-11-16T18:05:34Z</dc:date>
    </item>
    <item>
      <title>Re: How can I split two numbers from the same column in SAS EG 7.1?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-can-I-split-two-numbers-from-the-same-column-in-SAS-EG-7-1/m-p/514011#M2622</link>
      <description>COUNTW() to count the number of items&lt;BR /&gt;SCAN() to split. &lt;BR /&gt;temp = smi_error_code;&lt;BR /&gt;do i=1 to countw(temp, '|');&lt;BR /&gt;smi_error_code = scan(temp, i, '|');&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;</description>
      <pubDate>Fri, 16 Nov 2018 18:11:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-can-I-split-two-numbers-from-the-same-column-in-SAS-EG-7-1/m-p/514011#M2622</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-11-16T18:11:45Z</dc:date>
    </item>
    <item>
      <title>Re: How can I split two numbers from the same column in SAS EG 7.1?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-can-I-split-two-numbers-from-the-same-column-in-SAS-EG-7-1/m-p/514014#M2623</link>
      <description>&lt;P&gt;Code or task?&lt;/P&gt;
&lt;P&gt;Are all of the codes 5 characters or less?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Assuming a single code in that field appears as |30089| then this code should work. I have no ideas for task approaches:&lt;/P&gt;
&lt;PRE&gt;data want;  
   set have;
   /* the length below needs to be at least as large as
      your current code variable; 48 should work for up to
      8 code values
   */
   length oldcode $ 48.;
   retain oldcode;
   oldcode = code;
   do i=1 to ( countw(oldcode,'|') -1);
      code = scan(oldcode,i,'|');
      output;
   end;
   drop oldcode i;
run;&lt;/PRE&gt;
&lt;P&gt;The loop counter has -1 because your last delimiter | actually does not appear to have a value after it, so the count returned by COUNTW is one too large.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Nov 2018 18:20:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-can-I-split-two-numbers-from-the-same-column-in-SAS-EG-7-1/m-p/514014#M2623</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-11-16T18:20:22Z</dc:date>
    </item>
    <item>
      <title>Re: How can I split two numbers from the same column in SAS EG 7.1?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-can-I-split-two-numbers-from-the-same-column-in-SAS-EG-7-1/m-p/514019#M2625</link>
      <description>&lt;P&gt;This would split the numbers:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;...&lt;BR /&gt;
* For a code segment of 5 characters;&lt;BR /&gt;
do i = 2 to length( SMI_ERROR_CODE ) by 6;  &lt;BR /&gt;
   SMI_ERROR_CODE_new = substr( SMI_ERROR_CODE, i, 4 )&lt;BR /&gt;
output;
end;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Nov 2018 18:32:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-can-I-split-two-numbers-from-the-same-column-in-SAS-EG-7-1/m-p/514019#M2625</guid>
      <dc:creator>pink_poodle</dc:creator>
      <dc:date>2018-11-16T18:32:18Z</dc:date>
    </item>
  </channel>
</rss>

