<?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: Need to create a column based on sequence of variable appear in another column in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Need-to-create-a-column-based-on-sequence-of-variable-appear-in/m-p/550842#M76695</link>
    <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;&amp;nbsp;Thank you for your help.&lt;BR /&gt;I will work along this direction.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 29 Sep 2022 14:28:00 GMT</pubDate>
    <dc:creator>HSS</dc:creator>
    <dc:date>2022-09-29T14:28:00Z</dc:date>
    <item>
      <title>Need to create a column based on sequence of variable appear in another column</title>
      <link>https://community.jmp.com/t5/Discussions/Need-to-create-a-column-based-on-sequence-of-variable-appear-in/m-p/550790#M76680</link>
      <description>&lt;P&gt;Hi All,&lt;BR /&gt;I want to create a column based on &lt;STRONG&gt;:Client_ID&lt;/STRONG&gt; and how many times ( a number of sequence is counted as 1 count only, see the the &lt;STRONG&gt;:Comment&lt;/STRONG&gt; column) it is appearing in the data set. My requirement is :&lt;STRONG&gt;Final Requirement&lt;/STRONG&gt;&amp;nbsp; and would be happy to have :&lt;STRONG&gt;Required Column 1&lt;/STRONG&gt; as well. I can not re-arrange/sort the data.&lt;/P&gt;&lt;P&gt;Any help please ?&lt;/P&gt;&lt;P&gt;Many thanks, -HSS&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="HSS_1-1664455758344.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/45909iC16FCBF74EB01705/image-size/medium?v=v2&amp;amp;px=400" role="button" title="HSS_1-1664455758344.png" alt="HSS_1-1664455758344.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 15:59:22 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Need-to-create-a-column-based-on-sequence-of-variable-appear-in/m-p/550790#M76680</guid>
      <dc:creator>HSS</dc:creator>
      <dc:date>2023-06-09T15:59:22Z</dc:date>
    </item>
    <item>
      <title>Re: Need to create a column based on sequence of variable appear in another column</title>
      <link>https://community.jmp.com/t5/Discussions/Need-to-create-a-column-based-on-sequence-of-variable-appear-in/m-p/550808#M76681</link>
      <description>&lt;P&gt;Using associative array to store the value and then increase as needed should work here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Formula for Required Column 1:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;As Constant(
	aa = Associative Array(:Client_ID);
	aa = Associative Array(aa &amp;lt;&amp;lt; get keys, Repeat(0, N Items(aa)));
	retval = 1;
);
If(:Client_ID != Lag(:Client_ID),
	aa[:Client_ID]++;
);
aa[:Client_ID];
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And Final Requirement:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Eval Insert("^:Client_ID^_^:Required Column 2^");&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Example script (uses different column names):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = Open("$DOWNLOADS/data.jmp");

dt &amp;lt;&amp;lt; New Column("Required Column 2", Numeric, Ordinal, Formula(
	As Constant(
		aa = Associative Array(:Client_ID);
		aa = Associative Array(aa &amp;lt;&amp;lt; get keys, Repeat(0, N Items(aa)));
		retval = 1;
	);
	If(:Client_ID != Lag(:Client_ID),
		aa[:Client_ID]++;
	);
	aa[:Client_ID];
));

dt &amp;lt;&amp;lt; New Column("Final Requirement 2", Character, Ordinal, Formula(
	Eval Insert("^:Client_ID^_^:Required Column 2^");
));

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1664457060139.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/45910iE38011D5D7EA4362/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1664457060139.png" alt="jthi_0-1664457060139.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Sep 2022 13:12:05 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Need-to-create-a-column-based-on-sequence-of-variable-appear-in/m-p/550808#M76681</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-09-29T13:12:05Z</dc:date>
    </item>
    <item>
      <title>Re: Need to create a column based on sequence of variable appear in another column</title>
      <link>https://community.jmp.com/t5/Discussions/Need-to-create-a-column-based-on-sequence-of-variable-appear-in/m-p/550818#M76685</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;, Can I do the grouping also on "Associated Array" using another columns ? Something like&amp;nbsp; this ?&amp;nbsp;&lt;STRONG&gt;"Associated Array(:Client_ID, :Region)" &lt;/STRONG&gt;and my data set has more than 700000 rows, will the associate command still work ! If I can group by &lt;STRONG&gt;:Region&lt;/STRONG&gt;, it may still have more than 10000 rows. In any case, I will certainly try this.&lt;BR /&gt;Thank you for your help. Regards, - HSS&lt;/P&gt;</description>
      <pubDate>Thu, 29 Sep 2022 13:30:31 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Need-to-create-a-column-based-on-sequence-of-variable-appear-in/m-p/550818#M76685</guid>
      <dc:creator>HSS</dc:creator>
      <dc:date>2022-09-29T13:30:31Z</dc:date>
    </item>
    <item>
      <title>Re: Need to create a column based on sequence of variable appear in another column</title>
      <link>https://community.jmp.com/t5/Discussions/Need-to-create-a-column-based-on-sequence-of-variable-appear-in/m-p/550824#M76687</link>
      <description>&lt;P&gt;You would have to first create new "grouping" column if you wanted to use Associative Array like that. With multiple grouping columns, it might be easier to use Col Cumulative Sum (might be always easier, just came up with this). You will have to figure out correct comparison and the groupings&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Col Cumulative Sum(:Client_ID != Lag(:Client_ID), :Client_ID)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 29 Sep 2022 13:38:44 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Need-to-create-a-column-based-on-sequence-of-variable-appear-in/m-p/550824#M76687</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-09-29T13:38:44Z</dc:date>
    </item>
    <item>
      <title>Re: Need to create a column based on sequence of variable appear in another column</title>
      <link>https://community.jmp.com/t5/Discussions/Need-to-create-a-column-based-on-sequence-of-variable-appear-in/m-p/550832#M76691</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;&amp;nbsp;Col Cumulative Sum will work but I am not able to find a correct initialization of the loop/starting point with grouping variable :Region.&lt;BR /&gt;Any other suggestion?&lt;BR /&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;Col Cumulative Sum( :Client_ID != Lag( :Client_ID ) &amp;amp; :Region == Lag( :Region ), :Client_ID )&lt;/P&gt;</description>
      <pubDate>Thu, 29 Sep 2022 13:58:42 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Need-to-create-a-column-based-on-sequence-of-variable-appear-in/m-p/550832#M76691</guid>
      <dc:creator>HSS</dc:creator>
      <dc:date>2022-09-29T13:58:42Z</dc:date>
    </item>
    <item>
      <title>Re: Need to create a column based on sequence of variable appear in another column</title>
      <link>https://community.jmp.com/t5/Discussions/Need-to-create-a-column-based-on-sequence-of-variable-appear-in/m-p/550839#M76694</link>
      <description>&lt;P&gt;Easiest thing is most likely to create new column and then use that as grouping instead of :Client_ID (original formula)&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1664460322457.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/45911iE6FF63D471705296/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1664460322457.png" alt="jthi_0-1664460322457.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Col Cumulative Sum(:"Concatenate[Region,Client_ID]"n != Lag(:"Concatenate[Region,Client_ID]"n), :"Concatenate[Region,Client_ID]"n)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Otherwise the part which is summed in cumulative sum get more complicated quite fast (there might be easier ones than this, but this should handle wrong values on :Region change):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Col Cumulative Sum(
	If(Row() == Col Minimum(Row(), :Client_ID, :Region),
		1
	,
		:Client_ID != Lag(:Client_ID)
	)
	, :Client_ID, :Region
)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 29 Sep 2022 14:11:52 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Need-to-create-a-column-based-on-sequence-of-variable-appear-in/m-p/550839#M76694</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-09-29T14:11:52Z</dc:date>
    </item>
    <item>
      <title>Re: Need to create a column based on sequence of variable appear in another column</title>
      <link>https://community.jmp.com/t5/Discussions/Need-to-create-a-column-based-on-sequence-of-variable-appear-in/m-p/550842#M76695</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;&amp;nbsp;Thank you for your help.&lt;BR /&gt;I will work along this direction.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Sep 2022 14:28:00 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Need-to-create-a-column-based-on-sequence-of-variable-appear-in/m-p/550842#M76695</guid>
      <dc:creator>HSS</dc:creator>
      <dc:date>2022-09-29T14:28:00Z</dc:date>
    </item>
    <item>
      <title>Re: Need to create a column based on sequence of variable appear in another column</title>
      <link>https://community.jmp.com/t5/Discussions/Need-to-create-a-column-based-on-sequence-of-variable-appear-in/m-p/551259#M76716</link>
      <description>&lt;P&gt;Hi All,&lt;BR /&gt;&lt;BR /&gt;There is a further requirement - to add one more column &lt;STRONG&gt;:Req_3&lt;/STRONG&gt;,&amp;nbsp;where all the texts from &lt;STRONG&gt;:Group&lt;/STRONG&gt; would be combined and stored. &lt;STRONG&gt;:Group&lt;/STRONG&gt; text can be as long as 2 lines. Separator can be any thing.&lt;BR /&gt;&lt;BR /&gt;The problem is - number of cells need to be combined is not fix, it depends upon the value in column &lt;STRONG&gt;:Req_1.&lt;BR /&gt;&lt;BR /&gt;"Req_3" is required.&lt;BR /&gt;&lt;/STRONG&gt;Any help, Thanks.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="HSS_0-1664543873481.png" style="width: 454px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/45924iA71D9C7F627AF8FC/image-dimensions/454x355?v=v2" width="454" height="355" role="button" title="HSS_0-1664543873481.png" alt="HSS_0-1664543873481.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Sep 2022 13:27:24 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Need-to-create-a-column-based-on-sequence-of-variable-appear-in/m-p/551259#M76716</guid>
      <dc:creator>HSS</dc:creator>
      <dc:date>2022-09-30T13:27:24Z</dc:date>
    </item>
    <item>
      <title>Re: Need to create a column based on sequence of variable appear in another column</title>
      <link>https://community.jmp.com/t5/Discussions/Need-to-create-a-column-based-on-sequence-of-variable-appear-in/m-p/551265#M76718</link>
      <description>&lt;P&gt;Using SQL query (especially &lt;A href="https://www.jmp.com/support/help/en/16.2/index.shtml#page/jmp/aggregate-sql-functions.shtml#ww1000800" target="_self"&gt;GROUP_CONCAT&lt;/A&gt;) or JMP's different table operations (split, transpose, text to columns and combine columns, join back) might be easier than formula (and faster), but you could do it with a formula for example by using &lt;A href="https://www.jmp.com/support/help/en/16.2/#page/jmp/matrix-functions.shtml?os=win&amp;amp;source=application#ww2682950" target="_blank" rel="noopener"&gt;Loc()&lt;/A&gt; and indexing of different columns.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit: Added interactive method&lt;/P&gt;
&lt;P&gt;First split data:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1664550332275.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/45925i216B8C3B59956329/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1664550332275.png" alt="jthi_0-1664550332275.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Next transpose the split data:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_1-1664550375947.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/45926i906BE06104213E35/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_1-1664550375947.png" alt="jthi_1-1664550375947.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;From transposed data, first use text to columns to separate Req2 and Region from each other&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_2-1664550425860.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/45927i9893D754A9A391DF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_2-1664550425860.png" alt="jthi_2-1664550425860.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Then use combine columns to combine Row columns&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_3-1664550461910.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/45928iFB61520D6B4AA3B2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_3-1664550461910.png" alt="jthi_3-1664550461910.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Rename and remove unnecessary columns and you should end up with something like this&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_5-1664550570000.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/45930i2DD9CD3B8842AE5A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_5-1664550570000.png" alt="jthi_5-1664550570000.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Join this with the original data2&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_6-1664550598695.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/45931iD6E79460598C7F82/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_6-1664550598695.png" alt="jthi_6-1664550598695.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_7-1664550609644.png" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/45932i49C1A009082B6A1E/image-size/large?v=v2&amp;amp;px=999" role="button" title="jthi_7-1664550609644.png" alt="jthi_7-1664550609644.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Remove extra columns and you should have what you need.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Enhanced Log might have script ready for you, but you might have to clean it up a bit&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_8-1664550635747.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/45933iF04E52C23A6194E0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_8-1664550635747.png" alt="jthi_8-1664550635747.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Sep 2022 15:13:03 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Need-to-create-a-column-based-on-sequence-of-variable-appear-in/m-p/551265#M76718</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-09-30T15:13:03Z</dc:date>
    </item>
  </channel>
</rss>

