<?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: JSL : Use a checkbox with the levels of a column in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/JSL-Use-a-checkbox-with-the-levels-of-a-column/m-p/562565#M77555</link>
    <description>&lt;P&gt;'for each' is new to version 16.&amp;nbsp; If you have an older version then you can use a more traditional for-loop:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;		for (i=1,i&amp;lt;=nitems(selected),i++,
			rows = dt &amp;lt;&amp;lt; select  where(:Strength==selected[i],
				current selection("extend")
			);			
		);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 31 Oct 2022 17:19:50 GMT</pubDate>
    <dc:creator>David_Burnham</dc:creator>
    <dc:date>2022-10-31T17:19:50Z</dc:date>
    <item>
      <title>JSL : Use a checkbox with the levels of a column</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-Use-a-checkbox-with-the-levels-of-a-column/m-p/562445#M77541</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope you are doing well.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a question about the scripts of the checkboxes in JMP.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a data set with a "strength" variable, and I want to create a subset if the data set according to a checkbox presenting all the strengths in the data set. The aim is that the user check in the checkbox the strengths of interest and that the rows in the data set are selected according to the strengths checked in the checkbox. As the strengths are not necessary the same according to the data set,&amp;nbsp; I was wondering if it is possible to "extract" the unique values of strengths from the column and then to present the strengths in the checkbox in order to choose in the checkbox the strengths of interest. I want to have the script as general as possible to analyze all data sets with all possible strengths.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much and have a nice day,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jean&lt;/P&gt;</description>
      <pubDate>Sat, 10 Jun 2023 23:56:18 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-Use-a-checkbox-with-the-levels-of-a-column/m-p/562445#M77541</guid>
      <dc:creator>PersuasionCamel</dc:creator>
      <dc:date>2023-06-10T23:56:18Z</dc:date>
    </item>
    <item>
      <title>Re: JSL : Use a checkbox with the levels of a column</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-Use-a-checkbox-with-the-levels-of-a-column/m-p/562471#M77546</link>
      <description>&lt;P&gt;This example illustrates an approach that might work.&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 );

// mock up data set with Strength
dt = New Table( "Strength",
	New Column( "Strength", "Character", "Nominal",
		Values( {"Intelligent", "Innovative", "Initiative", "Introvert", "Intelligent",
			"Innovative", "Initiative", "Introvert", "Intelligent", "Innovative",
			"Initiative", "Introvert"} )
	)
);

// present user with choices
choice = Associative Array( :Strength ) &amp;lt;&amp;lt; Get Keys;
New Window( "Choose Strengths",
	Outline Box( "Pick Your Strengths from the Choices Below",
		Panel Box( "Strengths",
			Check Box( choice,
				&amp;lt;&amp;lt; Set Function(
					Function( { me, index }, { Default Local },
						selection = me &amp;lt;&amp;lt; Get Selected;
						n = N Items( selection );
						dt &amp;lt;&amp;lt; Clear Select;
						If(
							n == 1,
								Eval(
									Substitute(
										Expr( dt &amp;lt;&amp;lt; Select Where( :Strength == sss ) ),
										Expr( sss ), Name Expr( selection[1] )
									)
								),
							n &amp;gt; 0,
								sel expr = Expr( Or() );
								For( i = 1, i &amp;lt;= n, i++,
									equality = Substitute(
										Expr( :Strength == ccc ),
										Expr( ccc ), selection[i]
									);
									Insert Into( sel expr, Name Expr( equality ) );
								);
								Eval(
									Substitute(
										Expr( dt &amp;lt;&amp;lt; Select Where( eee ) ),
										Expr( eee ), Name Expr( sel expr )
									)
								);
						);
					);
				)
			)
		)
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 31 Oct 2022 13:45:53 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-Use-a-checkbox-with-the-levels-of-a-column/m-p/562471#M77546</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2022-10-31T13:45:53Z</dc:date>
    </item>
    <item>
      <title>Re: JSL : Use a checkbox with the levels of a column</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-Use-a-checkbox-with-the-levels-of-a-column/m-p/562550#M77552</link>
      <description>&lt;P&gt;An alternative example:&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 );

// mock up data set with Strength
dt = New Table( "Strength",
	New Column( "Strength", "Character", "Nominal",
		Values( {"Intelligent", "Innovative", "Initiative", "Introvert", "Intelligent",
			"Innovative", "Initiative", "Introvert", "Intelligent", "Innovative",
			"Initiative", "Introvert"} )
	)
);

// get unique values from the strength column
summarize(dt,levels=by(:strength));

// construct a window containing checkboxes
NewWindow("Selection",
	BorderBox(top(20),bottom(20),left(20),right(20),
		VListBox(
			TextBox("Select values:"),
			here:cb = CheckBox(levels),
			SpacerBox(size(0,20)),
			ButtonBox("Create Subset",doSubset())
		)
	)
);

// define function to perform when button is cliccked

doSubset = function({},{default local},

		dt = current data table();
		dt &amp;lt;&amp;lt; clear select;

		// get user selections
		selected = here:cb &amp;lt;&amp;lt; get selected;
		
		// iterate over each of the selected values
		// and select the associated rows
		for each( {selection},selected,
			rows = dt &amp;lt;&amp;lt; select  where(:Strength==selection,
				current selection("extend")
			);
		);
		// create a subset table
		dt &amp;lt;&amp;lt; subset(
			selected rows(1),
			selected columns only(0)
		);
		dt &amp;lt;&amp;lt; clear select;

);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Oct 2022 16:38:04 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-Use-a-checkbox-with-the-levels-of-a-column/m-p/562550#M77552</guid>
      <dc:creator>David_Burnham</dc:creator>
      <dc:date>2022-10-31T16:38:04Z</dc:date>
    </item>
    <item>
      <title>Re: JSL : Use a checkbox with the levels of a column</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-Use-a-checkbox-with-the-levels-of-a-column/m-p/562556#M77554</link>
      <description>&lt;P&gt;Hi David, thank you very much for your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, when the code is executed, I have ther following error :&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PersuasionCamel_0-1667234770749.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/46758i88DCA6536AF3F005/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PersuasionCamel_0-1667234770749.png" alt="PersuasionCamel_0-1667234770749.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;How can I fix it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much and have a nice day,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jean&lt;/P&gt;</description>
      <pubDate>Mon, 31 Oct 2022 16:46:43 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-Use-a-checkbox-with-the-levels-of-a-column/m-p/562556#M77554</guid>
      <dc:creator>PersuasionCamel</dc:creator>
      <dc:date>2022-10-31T16:46:43Z</dc:date>
    </item>
    <item>
      <title>Re: JSL : Use a checkbox with the levels of a column</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-Use-a-checkbox-with-the-levels-of-a-column/m-p/562565#M77555</link>
      <description>&lt;P&gt;'for each' is new to version 16.&amp;nbsp; If you have an older version then you can use a more traditional for-loop:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;		for (i=1,i&amp;lt;=nitems(selected),i++,
			rows = dt &amp;lt;&amp;lt; select  where(:Strength==selected[i],
				current selection("extend")
			);			
		);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 31 Oct 2022 17:19:50 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-Use-a-checkbox-with-the-levels-of-a-column/m-p/562565#M77555</guid>
      <dc:creator>David_Burnham</dc:creator>
      <dc:date>2022-10-31T17:19:50Z</dc:date>
    </item>
    <item>
      <title>Re: JSL : Use a checkbox with the levels of a column</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-Use-a-checkbox-with-the-levels-of-a-column/m-p/562759#M77580</link>
      <description>&lt;P&gt;Thank you very much !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Two last questions:&lt;/P&gt;&lt;P&gt;- Is there any command to close or hide the subset of the data set ?&lt;/P&gt;&lt;P&gt;- If I have already a dataset opened in Jmp, how can I defined it in a &lt;EM&gt;dt&lt;/EM&gt; variable?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much and have a nice day,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jean&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2022 08:18:42 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-Use-a-checkbox-with-the-levels-of-a-column/m-p/562759#M77580</guid>
      <dc:creator>PersuasionCamel</dc:creator>
      <dc:date>2022-11-01T08:18:42Z</dc:date>
    </item>
    <item>
      <title>Re: JSL : Use a checkbox with the levels of a column</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-Use-a-checkbox-with-the-levels-of-a-column/m-p/562782#M77581</link>
      <description>&lt;P&gt;Thank you very much ! Is the subset stored in the dt2 variable ?&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2022 09:08:36 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-Use-a-checkbox-with-the-levels-of-a-column/m-p/562782#M77581</guid>
      <dc:creator>PersuasionCamel</dc:creator>
      <dc:date>2022-11-01T09:08:36Z</dc:date>
    </item>
    <item>
      <title>Re: JSL : Use a checkbox with the levels of a column</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-Use-a-checkbox-with-the-levels-of-a-column/m-p/562853#M77593</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;Is the subset stored in the dt2 variable&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Only if you define a dt2 variable :)&lt;/img&gt;&lt;/P&gt;
&lt;P&gt;You can do this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;		dt2 = dt &amp;lt;&amp;lt; subset(
			selected rows(1),
			selected columns only(0)
		);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;Is there any command to close or hide the subset of the data set&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Since we've only just created it I assume we don't want to close it, but if you don't want the user to see it you can make it invisible:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;		dt2 = dt &amp;lt;&amp;lt; subset( invisible,
			selected rows(1),
			selected columns only(0)
		);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;If I have already a dataset opened in Jmp, how can I defined it in a&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;dt&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;variable&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You can either associate the dt variable to the current open table,&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = current data table();&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or if there are multiple tables open, by referencing the table:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = data table("strength data");&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Finally, a question you didn't ask but might be wondering.&amp;nbsp; Once the user has clicked the button to create the subset, if you want to close the window containing the checkboxes you can add the following lines to the end of the &lt;EM&gt;doSubset&lt;/EM&gt; function:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;cr = current report();
cr &amp;lt;&amp;lt; close window;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Good luck.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2022 13:25:50 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-Use-a-checkbox-with-the-levels-of-a-column/m-p/562853#M77593</guid>
      <dc:creator>David_Burnham</dc:creator>
      <dc:date>2022-11-01T13:25:50Z</dc:date>
    </item>
    <item>
      <title>Re: JSL : Use a checkbox with the levels of a column</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-Use-a-checkbox-with-the-levels-of-a-column/m-p/562933#M77600</link>
      <description>&lt;P&gt;All good !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have a very nice day,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jean&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2022 14:40:30 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-Use-a-checkbox-with-the-levels-of-a-column/m-p/562933#M77600</guid>
      <dc:creator>PersuasionCamel</dc:creator>
      <dc:date>2022-11-01T14:40:30Z</dc:date>
    </item>
    <item>
      <title>Re: JSL : Use a checkbox with the levels of a column</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-Use-a-checkbox-with-the-levels-of-a-column/m-p/564316#M77681</link>
      <description>&lt;P&gt;Hello again,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a very last question: how can I modify the code to name each subset by the strengths that were checked in the checkbox ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much and have a nice day,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jean&lt;/P&gt;</description>
      <pubDate>Thu, 03 Nov 2022 15:02:52 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-Use-a-checkbox-with-the-levels-of-a-column/m-p/564316#M77681</guid>
      <dc:creator>PersuasionCamel</dc:creator>
      <dc:date>2022-11-03T15:02:52Z</dc:date>
    </item>
  </channel>
</rss>

