<?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: isolate several values in the same cell in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/isolate-several-values-in-the-same-cell/m-p/412274#M26490</link>
    <description>&lt;P&gt;Its more of a data cleaning issue.&amp;nbsp; Why do you have a variable with multiple data items in it.&amp;nbsp; Step one will be to split them into their own variables.&amp;nbsp; For instance, you could code around it, but you may cause further problems. Take:&lt;BR /&gt;B not A&lt;/P&gt;
&lt;P&gt;As a string, should A be there?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Me I would process table A to look more like:&lt;BR /&gt;KEY&amp;nbsp; &amp;nbsp; VALUE1&amp;nbsp; &amp;nbsp; VALUE2&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; B&lt;/P&gt;
&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;A&lt;/P&gt;
&lt;P&gt;3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;B&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can then simply merge based on value=value1 or value=value2.&amp;nbsp; Obviously this doesn't really show it well, but I can only work with what you provide here.&lt;/P&gt;</description>
    <pubDate>Fri, 10 Nov 2017 11:22:06 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2017-11-10T11:22:06Z</dc:date>
    <item>
      <title>isolate several values in the same cell</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/isolate-several-values-in-the-same-cell/m-p/412273#M26489</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I own 2 tables in my program.&lt;BR /&gt;&lt;BR /&gt;table A&lt;BR /&gt;&lt;BR /&gt;key;value&lt;BR /&gt;key1;A and B&lt;BR /&gt;key2;A&lt;BR /&gt;key3;B&lt;BR /&gt;&lt;BR /&gt;table B&lt;BR /&gt;value;value_text&lt;BR /&gt;A;text a&lt;BR /&gt;B;text b&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want receive each line of the table A with the value "value_text" of the table B . There is a problem , tableA.value can contain "A and B" in the even cell ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;select tableA.key , tableA.value , tableB.value
from tableA
inner join SUBSTR(tableA.value,INDEX(cats(tableA.value),tableB.value)length(tableB.value))) = tableB.value&lt;/PRE&gt;&lt;P&gt;An idea if the query is logical or an other solution exist ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for you help.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2017 11:18:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/isolate-several-values-in-the-same-cell/m-p/412273#M26489</guid>
      <dc:creator>azertyuiop</dc:creator>
      <dc:date>2017-11-10T11:18:10Z</dc:date>
    </item>
    <item>
      <title>Re: isolate several values in the same cell</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/isolate-several-values-in-the-same-cell/m-p/412274#M26490</link>
      <description>&lt;P&gt;Its more of a data cleaning issue.&amp;nbsp; Why do you have a variable with multiple data items in it.&amp;nbsp; Step one will be to split them into their own variables.&amp;nbsp; For instance, you could code around it, but you may cause further problems. Take:&lt;BR /&gt;B not A&lt;/P&gt;
&lt;P&gt;As a string, should A be there?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Me I would process table A to look more like:&lt;BR /&gt;KEY&amp;nbsp; &amp;nbsp; VALUE1&amp;nbsp; &amp;nbsp; VALUE2&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; B&lt;/P&gt;
&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;A&lt;/P&gt;
&lt;P&gt;3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;B&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can then simply merge based on value=value1 or value=value2.&amp;nbsp; Obviously this doesn't really show it well, but I can only work with what you provide here.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2017 11:22:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/isolate-several-values-in-the-same-cell/m-p/412274#M26490</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-11-10T11:22:06Z</dc:date>
    </item>
    <item>
      <title>Re: isolate several values in the same cell</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/isolate-several-values-in-the-same-cell/m-p/412297#M26499</link>
      <description>&lt;P&gt;Hello ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The table in enter contain 2 column s.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the field "VALUE" if you found "A and B" it's a string text which is contained in one cell of the table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I search to use text function in sas to obtain 2 lines , one line with the value "A" and an other line with the value "B" .&lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2017 12:46:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/isolate-several-values-in-the-same-cell/m-p/412297#M26499</guid>
      <dc:creator>azertyuiop</dc:creator>
      <dc:date>2017-11-10T12:46:25Z</dc:date>
    </item>
    <item>
      <title>Re: isolate several values in the same cell</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/isolate-several-values-in-the-same-cell/m-p/412404#M26524</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/165260"&gt;@azertyuiop&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hello ,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The table in enter contain 2 column s.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the field "VALUE" if you found "A and B" it's a string text which is contained in one cell of the table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I search to use text function in sas to obtain 2 lines , one line with the value "A" and an other line with the value "B" .&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Instead, consider posting sample data and the corresponding expected output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2017 16:02:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/isolate-several-values-in-the-same-cell/m-p/412404#M26524</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-11-10T16:02:51Z</dc:date>
    </item>
    <item>
      <title>Re: isolate several values in the same cell</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/isolate-several-values-in-the-same-cell/m-p/412816#M26545</link>
      <description>&lt;P&gt;Hello / Good morning ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is an concret example :&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="Sans titre.png" style="width: 611px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/16596i9DA62E84CF3DF241/image-dimensions/611x270?v=v2" width="611" height="270" role="button" title="Sans titre.png" alt="Sans titre.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;TableA and TableB the tables in enter . Te tableC is for the result. When there is the value " and " is the cell I want create 2 lines with each value , value before " and " and after " and " .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want execute this query under SAS :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Create table tablec_result as

select distinct
tablea.keys ,
tablea.text_value ,
tableb.text_value ,
tableb.code_value ,
length(tablea.text_value) ,
left(tablea.text_value,length(tableb.text_value)) ,
substr(tablea.text_value,index(tablea.text_value,tableb.text_value)-length(tableb.text_value),length(tableb.text_value))
from work.tablea
inner join work.tableb on index(tablea.text_value,tableb.text_value)= tableb.text_value
and tableb.text_value like substr(tablea.text_value,index(tablea.text_value,tableb.text_value)-length(tableb.text_value),length(tableb.text_value)))
and tablea.text_value like '% and %' ;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The solution is possible in SQl because after a test with a another SGBD (mysql) in an other server , this query is ok. I want translate the query in SAS case.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks to correct and give your opinion &lt;img id="manvery-happy" class="emoticon emoticon-manvery-happy" src="https://communities.sas.com/i/smilies/16x16_man-very-happy.png" alt="Man Very Happy" title="Man Very Happy" /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2017 09:20:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/isolate-several-values-in-the-same-cell/m-p/412816#M26545</guid>
      <dc:creator>azertyuiop</dc:creator>
      <dc:date>2017-11-13T09:20:08Z</dc:date>
    </item>
    <item>
      <title>Re: isolate several values in the same cell</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/isolate-several-values-in-the-same-cell/m-p/412820#M26546</link>
      <description>&lt;P&gt;Step1: Take table A and create the list of data items, not combined - note as you refuse to post test data in a usable format this is just psuedocode:&lt;/P&gt;
&lt;PRE&gt;data inter_tablea;
  set tablea;
  length text_values_sample $50;
  if index(text_values,"AND") &amp;gt; 0 then do;
    text_values_sample=substr(text_values,1,findw(text_values,"AND"));
    output;
    text_values_sample=substr(findw(text_values,"AND")+3));
    output;
  end;
  else do;
    text_values_sample=text_values;
    output;
  end;
run;&lt;/PRE&gt;
&lt;P&gt;That is the only real problem here is that the "data" is all squashed into one variable.&amp;nbsp; Once you separate out the data items into (in the above case) observations (but you could also do it with two variables) then the merge itself becomes very simple.&lt;/P&gt;
&lt;P&gt;Note that you can't really do the index merge as you have elements like:&lt;/P&gt;
&lt;P&gt;TEXT BB, which contains TEXT BB and TEXT B, so you need to process these before merging.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2017 09:29:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/isolate-several-values-in-the-same-cell/m-p/412820#M26546</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-11-13T09:29:30Z</dc:date>
    </item>
    <item>
      <title>Re: isolate several values in the same cell</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/isolate-several-values-in-the-same-cell/m-p/412832#M26547</link>
      <description>&lt;P&gt;Hello ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Due to an error in your code I permit to modify this&amp;nbsp; by this :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data inter_tablea; 
set inter_tablea;

    do i=1 to count(text_values, "and", " ")+1;
      text_values_sample=scan(tranwrd(text_values," and ",";"),-i,";");
       output;
     end;
run;&lt;/PRE&gt;&lt;P&gt;Here there is only one step. SAS break each line where there are several values with "and" separator.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tested your code and there are 2 errors which are detected by SAS :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;text_values_sample=substr(findw(text_values,"AND")+3);
    output;&lt;/PRE&gt;&lt;P&gt;An error in the " findw " function , which isn't read by SAS .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The second error it's SAS which can't create the table "inter_tablea" .&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2017 10:46:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/isolate-several-values-in-the-same-cell/m-p/412832#M26547</guid>
      <dc:creator>azertyuiop</dc:creator>
      <dc:date>2017-11-13T10:46:04Z</dc:date>
    </item>
    <item>
      <title>Re: isolate several values in the same cell</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/isolate-several-values-in-the-same-cell/m-p/412833#M26548</link>
      <description>&lt;P&gt;Yes, I believe I mentioned that the code is not tested.&amp;nbsp; When posting a question there is a guidance box by the Post button, which shows you what information to post.&amp;nbsp; This includes, but is not limited to test data - in the form of a datastep in a code window (its the {i} above the post area), required output,Logs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This information is necessary as we cannot see your machine, we don't know what your doing, and hence we have to guess.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This "&lt;SPAN&gt;which isn't read by SAS" - does not tell me anything?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;I guess the error is because there is a typo:&lt;/P&gt;
&lt;PRE&gt;    text_values_sample=substr(findw(text_values,"AND")+3));&lt;/PRE&gt;
&lt;P&gt;Should be:&lt;/P&gt;
&lt;PRE&gt;    text_values_sample=substr(text_value,findw(text_values,"AND")+3));
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;You can do it your way, its fine, the basic concept is to break the column which has multiple data items into separate entries, either observations or columns.&amp;nbsp; You should always keep individual data items in their own column or observation - this is to make processing that data easier.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2017 11:04:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/isolate-several-values-in-the-same-cell/m-p/412833#M26548</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-11-13T11:04:34Z</dc:date>
    </item>
    <item>
      <title>Re: isolate several values in the same cell</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/isolate-several-values-in-the-same-cell/m-p/413254#M26570</link>
      <description>I test you solution later in an other program ans I gave a result.</description>
      <pubDate>Tue, 14 Nov 2017 10:12:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/isolate-several-values-in-the-same-cell/m-p/413254#M26570</guid>
      <dc:creator>azertyuiop</dc:creator>
      <dc:date>2017-11-14T10:12:59Z</dc:date>
    </item>
  </channel>
</rss>

