<?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 to split multi-word-values and re-arranging them in alphabetical order in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-split-multi-word-values-and-re-arranging-them-in/m-p/329554#M57873</link>
    <description>&lt;P&gt;It's not often that I can improve on&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2687"&gt;@txnelson&lt;/a&gt;, but I can get it down to a one line formula:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Concat Items( Sort List( Words( :Current data, "/" ) ), "/" )&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;A href="https://www.jmp.com/support/help/en/15.2/jmp/list-functions.shtml#ww2491421" target="_self"&gt;Words()&lt;/A&gt; creates a list of words by breaking the column into words using a "/" as delimiter.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.jmp.com/support/help/en/15.2/jmp/list-functions.shtml#ww5022389" target="_self"&gt;Sort List()&lt;/A&gt; sorts the list alphabetically&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.jmp.com/support/help/en/15.2/jmp/list-functions.shtml#ww4578477" target="_self"&gt;Concat Items()&lt;/A&gt; concatenates the items in the list into a single string using the "/" to separate the items.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2020-11-03_17-28-35.272.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/28065i9F87EE1EA7A0E4DF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="2020-11-03_17-28-35.272.png" alt="2020-11-03_17-28-35.272.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt; &lt;/P&gt;</description>
    <pubDate>Tue, 03 Nov 2020 22:29:02 GMT</pubDate>
    <dc:creator>Jeff_Perkinson</dc:creator>
    <dc:date>2020-11-03T22:29:02Z</dc:date>
    <item>
      <title>How to split multi-word-values and re-arranging them in alphabetical order</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-split-multi-word-values-and-re-arranging-them-in/m-p/329531#M57869</link>
      <description>&lt;P&gt;I have a column with character values that are two letter abbreviations. Some are single values and others are multiple values separated by the delimiter “/”. The problem is that the multi-value values are not in alphabetical order.&lt;BR /&gt;I want to iterate through each row and split the multi-values and re arrange them in alphabetical order and insert the new "value" in a New Column. Single values should be just "Copied" and nulls left as nulls.&lt;BR /&gt;This is way over my head and I will appreciate any suggestions pointers or reading lists to help me fix this one.&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Current data&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;NEW Data&lt;BR /&gt;AB&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AB&lt;BR /&gt;CD&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;CD&lt;BR /&gt;EF&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; EF&lt;BR /&gt;CD/AB&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;AB/CD&lt;BR /&gt;null&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; null&lt;BR /&gt;EF/AB/CD&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;AB/CD/EF&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;col = ("Really | Long | and | Boring | Column | Name");

Vals = As Column (col) &amp;lt;&amp;lt; Get Values;  // Get Values 

dt = New Column ("NewAbs", Character, "Nominal" );  //New column for NEW DATA
rows = N rows (dt); // Total number of rows to iterate

for(i = 1 , i &amp;lt;= rows, i++,
	if(rowVal (Contains (Vals[i], "/")),  // check if is multi-value i.e. AB/DF
	rowVal = Words(Vals[i],"/");  // Words will split multi-values at "/" 
	sval = Sort List(Eval List(rowVal) );  // sort the character values
	
	For(i = 1, i &amp;lt;= N Items (sVal), i++,
	newVal = sVal[i];
	conCat = Concat Items ( newVal[i] || "/"|| newVal[i+i])
		
	),
	Insert Into (dt, conCat[i]),
		if(rowVal (!Contains (Vals[i], "/")),  // if is NOT multi-value i.e. AB/DF
		Insert Into (dt, rowVal[i])),
	 ),
   );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 09 Jun 2023 23:42:17 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-split-multi-word-values-and-re-arranging-them-in/m-p/329531#M57869</guid>
      <dc:creator>ALopez</dc:creator>
      <dc:date>2023-06-09T23:42:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to split multi-word-values and re-arranging them in alphabetical order</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-split-multi-word-values-and-re-arranging-them-in/m-p/329550#M57870</link>
      <description>&lt;P&gt;Here is a formula that works on your sample data table.&amp;nbsp; Attached is a data table with the formula applied&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;If( Contains( :Current data, "/" ) == 0,
	x = :Current data,
	i = 1;
	theList = {};
	While( Word( i, :Current data, "/" ) != "",
		Insert Into( theList, Word( i, :Current data, "/" ) );
		i++;
	);
	theList = Sort List( theList );
	x = theList[1];
	For( i = 2, i &amp;lt;= N Items( theList ), i++,
		x = x || "/" || theList[i]
	);
)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 03 Nov 2020 22:13:18 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-split-multi-word-values-and-re-arranging-them-in/m-p/329550#M57870</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-11-03T22:13:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to split multi-word-values and re-arranging them in alphabetical order</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-split-multi-word-values-and-re-arranging-them-in/m-p/329554#M57873</link>
      <description>&lt;P&gt;It's not often that I can improve on&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2687"&gt;@txnelson&lt;/a&gt;, but I can get it down to a one line formula:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Concat Items( Sort List( Words( :Current data, "/" ) ), "/" )&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;A href="https://www.jmp.com/support/help/en/15.2/jmp/list-functions.shtml#ww2491421" target="_self"&gt;Words()&lt;/A&gt; creates a list of words by breaking the column into words using a "/" as delimiter.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.jmp.com/support/help/en/15.2/jmp/list-functions.shtml#ww5022389" target="_self"&gt;Sort List()&lt;/A&gt; sorts the list alphabetically&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.jmp.com/support/help/en/15.2/jmp/list-functions.shtml#ww4578477" target="_self"&gt;Concat Items()&lt;/A&gt; concatenates the items in the list into a single string using the "/" to separate the items.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2020-11-03_17-28-35.272.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/28065i9F87EE1EA7A0E4DF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="2020-11-03_17-28-35.272.png" alt="2020-11-03_17-28-35.272.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt; &lt;/P&gt;</description>
      <pubDate>Tue, 03 Nov 2020 22:29:02 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-split-multi-word-values-and-re-arranging-them-in/m-p/329554#M57873</guid>
      <dc:creator>Jeff_Perkinson</dc:creator>
      <dc:date>2020-11-03T22:29:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to split multi-word-values and re-arranging them in alphabetical order</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-split-multi-word-values-and-re-arranging-them-in/m-p/329557#M57876</link>
      <description>Very, very nice</description>
      <pubDate>Tue, 03 Nov 2020 22:51:36 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-split-multi-word-values-and-re-arranging-them-in/m-p/329557#M57876</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-11-03T22:51:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to split multi-word-values and re-arranging them in alphabetical order</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-split-multi-word-values-and-re-arranging-them-in/m-p/329754#M57895</link>
      <description>&lt;P&gt;Dear&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2687"&gt;@txnelson&lt;/a&gt;&amp;nbsp; and&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/6878"&gt;@Jeff_Perkinson&lt;/a&gt;&amp;nbsp; Thank you very much for your answers;&amp;nbsp; 0ne a great lesson about loops and the other a mind boggling one-liner.&lt;/P&gt;&lt;P&gt;I will add both to my bag of JSL.&lt;/P&gt;&lt;P&gt;Best regards.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Nov 2020 15:43:23 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-split-multi-word-values-and-re-arranging-them-in/m-p/329754#M57895</guid>
      <dc:creator>ALopez</dc:creator>
      <dc:date>2020-11-04T15:43:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to split multi-word-values and re-arranging them in alphabetical order</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-split-multi-word-values-and-re-arranging-them-in/m-p/331166#M58001</link>
      <description>&lt;P&gt;In addition to segmentation and sorting, does this formula add and remove the duplicated values after segmentation and keep only the fields that do not repeat?Such as:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2020-11-09_16-23-57.png" style="width: 727px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/28179i6E4CE5889AF0691B/image-size/large?v=v2&amp;amp;px=999" role="button" title="2020-11-09_16-23-57.png" alt="2020-11-09_16-23-57.png" /&gt;&lt;/span&gt;&lt;BR /&gt;Best regards.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Nov 2020 08:31:13 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-split-multi-word-values-and-re-arranging-them-in/m-p/331166#M58001</guid>
      <dc:creator>lwx228</dc:creator>
      <dc:date>2020-11-09T08:31:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to split multi-word-values and re-arranging them in alphabetical order</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-split-multi-word-values-and-re-arranging-them-in/m-p/331271#M58002</link>
      <description>&lt;P&gt;No, neither solution specified removes duplicates.&amp;nbsp; That requirement was not part of the original request.&lt;/P&gt;
&lt;P&gt;The Contains() function has the ability to check across items in a list to see if a match is found.&amp;nbsp; I use it quite often.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
theList = {"AB", "AB", "CD", "EF"};
x = {};
Insert Into( x, theList[1] );
For( i = 2, i &amp;lt;= N Items( theList ), i++,
	If( Contains( x, theList[i] ) == 0,
		Insert Into( x, theList[i] )
	)
);
show(x);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So all that has to be done, is to place this code into one or the other suggested solutions.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;x = :Current data;
If( Contains( x, "/" ) &amp;gt; 0,
	theList = Words( x, "/" );
	theList = Sort List( theList );
	x = {};
	Insert Into( x, theList[1] );
	For( i = 2, i &amp;lt;= N Items( theList ), i++,
		If( Contains( x, theList[i] ) == 0,
			Insert Into( x, theList[i] )
		)
	);
	x = Concat Items( x, "/" );
);
x;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 09 Nov 2020 11:07:24 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-split-multi-word-values-and-re-arranging-them-in/m-p/331271#M58002</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-11-09T11:07:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to split multi-word-values and re-arranging them in alphabetical order</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-split-multi-word-values-and-re-arranging-them-in/m-p/331318#M58009</link>
      <description>&lt;P&gt;This example illustrates another approach using dictionaries:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
theList = {"AB", "AB", "CD", "EF"};

theArray = Associative Array( theList );

theNewList = theArray &amp;lt;&amp;lt; Get Keys;

Show( theNewList );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 09 Nov 2020 13:15:19 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-split-multi-word-values-and-re-arranging-them-in/m-p/331318#M58009</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2020-11-09T13:15:19Z</dc:date>
    </item>
  </channel>
</rss>

