<?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: split one string into multiple row in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/split-one-string-into-multiple-row/m-p/566222#M33992</link>
    <description>&lt;P&gt;"&lt;SPAN&gt;Reading the code, &lt;U&gt;my assumption is that there's a variable in the data set called teste that the users is temporarily renaming to funcoes&lt;/U&gt; so that the output variable can be reset. Though that could still cause issues."&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Oh well, that's super diligence. You beat me big time&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 14 Jun 2019 15:58:45 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2019-06-14T15:58:45Z</dc:date>
    <item>
      <title>split one string into multiple row</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/split-one-string-into-multiple-row/m-p/566202#M33984</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am having trouble using the scan function.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to split the information separated by comma in a column, just like the example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;User&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Funcoes&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;12345&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;A,B,C,D,,E,F,G,...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I want is something like&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;User&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Funcoes&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;12345&amp;nbsp; &amp;nbsp; &amp;nbsp; A&lt;/P&gt;&lt;P&gt;12345&amp;nbsp; &amp;nbsp; &amp;nbsp; B&lt;/P&gt;&lt;P&gt;12345&amp;nbsp; &amp;nbsp; &amp;nbsp; C&lt;/P&gt;&lt;P&gt;12345&amp;nbsp; &amp;nbsp; &amp;nbsp; D&lt;/P&gt;&lt;P&gt;12345&amp;nbsp; &amp;nbsp; &amp;nbsp; E&lt;/P&gt;&lt;P&gt;12345&amp;nbsp; &amp;nbsp; &amp;nbsp; F&lt;/P&gt;&lt;P&gt;12345&amp;nbsp; &amp;nbsp; &amp;nbsp; G&lt;/P&gt;&lt;P&gt;12345&amp;nbsp; &amp;nbsp; &amp;nbsp;...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.teste;
   set WORK.TESTE;
   Funcoes= teste;
   do i= 1 to (countw(Funcoes));
      teste = scan(Funcoes, i,',');
      output;
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I am trying this code but it is not returning any values.&lt;/P&gt;&lt;P&gt;Can you help me?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance,&lt;/P&gt;&lt;P&gt;Rita&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jun 2019 15:21:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/split-one-string-into-multiple-row/m-p/566202#M33984</guid>
      <dc:creator>Rita_Viegas</dc:creator>
      <dc:date>2019-06-14T15:21:21Z</dc:date>
    </item>
    <item>
      <title>Re: split one string into multiple row</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/split-one-string-into-multiple-row/m-p/566204#M33985</link>
      <description>&lt;P&gt;Note that you are overwriting your input. That could cause trouble.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Describe more what is happening. Are you getting errors in the log?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jun 2019 15:24:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/split-one-string-into-multiple-row/m-p/566204#M33985</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-06-14T15:24:01Z</dc:date>
    </item>
    <item>
      <title>Re: split one string into multiple row</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/split-one-string-into-multiple-row/m-p/566208#M33986</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am not getting any error.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The output data does not returning anything. Just the name of the columns.&lt;/P&gt;&lt;P&gt;Probably my program is not correct. I am not an expert user &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Rita&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jun 2019 15:27:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/split-one-string-into-multiple-row/m-p/566208#M33986</guid>
      <dc:creator>Rita_Viegas</dc:creator>
      <dc:date>2019-06-14T15:27:27Z</dc:date>
    </item>
    <item>
      <title>Re: split one string into multiple row</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/split-one-string-into-multiple-row/m-p/566213#M33987</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/125604"&gt;@Rita_Viegas&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data test;
input User        Funcoes :$30.;
cards;
12345       A,B,C,D,,E,F,G
;



data youwant_this;
   set test;
/*   Funcoes= teste;this is wrong */
   do i= 1 to (countw(Funcoes,','));
      teste = scan(Funcoes, i,',');
      output;
   end;
run;

data or_you_want_this;
   set test;
/*   Funcoes= teste;this is wrong*/
   do i= 1 to (countw(Funcoes,',','m'));
      teste = scan(Funcoes, i,',','m');
      output;
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 14 Jun 2019 15:40:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/split-one-string-into-multiple-row/m-p/566213#M33987</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-06-14T15:40:43Z</dc:date>
    </item>
    <item>
      <title>Re: split one string into multiple row</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/split-one-string-into-multiple-row/m-p/566214#M33988</link>
      <description>&lt;P&gt;Provide example data is the form of a data step and paste into a code box opened with the forum's {I} or "running man" icon.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data have;
   infile datalines dlm=' ';
   input user $ funcoes $15.;
datalines;
12345 A,B,C,D,,E,F,G
;

data want;
   set have;
   length teste $ 1;
   do i= 1 to (countw(Funcoes));
      teste = scan(Funcoes, i,',');
      if not missing(teste) then output;
   end;
   drop I funcoes;
run;&lt;/PRE&gt;
&lt;P&gt;The length for TESTE should be longest value expect to extract from the FUNCOES string.&lt;/P&gt;
&lt;P&gt;Since your example data had a missing value between D and E that did not appear in the desired output I added a test for a non-missing TESTE value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jun 2019 15:41:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/split-one-string-into-multiple-row/m-p/566214#M33988</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-06-14T15:41:10Z</dc:date>
    </item>
    <item>
      <title>Re: split one string into multiple row</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/split-one-string-into-multiple-row/m-p/566215#M33989</link>
      <description>&lt;P&gt;Your code looks correct. But, can you open up your original data set and make sure it's still valid? Your style of coding (same data set input and output names) can destroy the original data set and makes it really hard to debug issues.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try recreating it, and then running this version and posting the log back.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.teste2;
   set WORK.TESTE;
   Funcoes= teste;
   do i= 1 to (countw(Funcoes));
      teste = scan(Funcoes, i,',');
      output;
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/125604"&gt;@Rita_Viegas&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am not getting any error.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The output data does not returning anything. Just the name of the columns.&lt;/P&gt;
&lt;P&gt;Probably my program is not correct. I am not an expert user &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you,&lt;/P&gt;
&lt;P&gt;Rita&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jun 2019 15:43:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/split-one-string-into-multiple-row/m-p/566215#M33989</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-06-14T15:43:10Z</dc:date>
    </item>
    <item>
      <title>Re: split one string into multiple row</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/split-one-string-into-multiple-row/m-p/566217#M33990</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp; &amp;nbsp;You should start drinking coffee as I have always recommended Starbucks as opposed to Canada's favorite Tim hortons lol.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt; Funcoes= teste;&lt;/STRONG&gt;&amp;nbsp; causes Funcoes to be set to missing as teste is an assignment that is reset to missing at the beginning of each iteration of the datastep.&amp;nbsp; So I commented that part.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jun 2019 15:52:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/split-one-string-into-multiple-row/m-p/566217#M33990</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-06-14T15:52:57Z</dc:date>
    </item>
    <item>
      <title>Re: split one string into multiple row</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/split-one-string-into-multiple-row/m-p/566220#M33991</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp; &amp;nbsp;You should start drinking coffee as I have always recommended Starbucks as opposed to Canada's favorite Tim hortons lol.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt; Funcoes= teste;&lt;/STRONG&gt;&amp;nbsp; causes Funcoes to be set to missing as teste is an assignment that is reset to missing at the beginning of each iteration of the datastep.&amp;nbsp; So I commented that part.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;I don't drink any coffee -- maybe that's the problem &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt; Actually Starbucks Hibiscus tea (well caffeinated) is currently my favourite drink!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Reading the code, my assumption is that there's a variable in the data set called teste that the users is temporarily renaming to funcoes so that the output variable can be reset. Though that could still cause issues.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jun 2019 15:57:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/split-one-string-into-multiple-row/m-p/566220#M33991</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-06-14T15:57:18Z</dc:date>
    </item>
    <item>
      <title>Re: split one string into multiple row</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/split-one-string-into-multiple-row/m-p/566222#M33992</link>
      <description>&lt;P&gt;"&lt;SPAN&gt;Reading the code, &lt;U&gt;my assumption is that there's a variable in the data set called teste that the users is temporarily renaming to funcoes&lt;/U&gt; so that the output variable can be reset. Though that could still cause issues."&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Oh well, that's super diligence. You beat me big time&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jun 2019 15:58:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/split-one-string-into-multiple-row/m-p/566222#M33992</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-06-14T15:58:45Z</dc:date>
    </item>
    <item>
      <title>Re: split one string into multiple row</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/split-one-string-into-multiple-row/m-p/566224#M33993</link>
      <description>It's not necessarily right though - only the OP knows &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Fri, 14 Jun 2019 16:07:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/split-one-string-into-multiple-row/m-p/566224#M33993</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-06-14T16:07:34Z</dc:date>
    </item>
    <item>
      <title>Re: split one string into multiple row</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/split-one-string-into-multiple-row/m-p/566226#M33994</link>
      <description>&lt;P&gt;I suspect that the OP saw a similar assignment statement in an old program where it was meant to create a new character variable with the same length as the original variable. Of course, the correct implementation of this technique would have been&amp;nbsp;&lt;FONT face="courier new,courier"&gt;teste=Funcoes;&lt;/FONT&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, with the current release of SAS 9.4 this is redundant because the &lt;A href="https://documentation.sas.com/#p1ui6lwbqstz86n1jzsu8ifdhu5j" target="_blank" rel="noopener"&gt;behavior of the SCAN function has changed&lt;/A&gt; so that the default length of &lt;FONT face="courier new,courier"&gt;teste&lt;/FONT&gt; is that of &lt;FONT face="courier new,courier"&gt;Funcoes&lt;/FONT&gt; (and not 200 in most cases).&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jun 2019 16:14:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/split-one-string-into-multiple-row/m-p/566226#M33994</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2019-06-14T16:14:25Z</dc:date>
    </item>
  </channel>
</rss>

