<?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: Get column names that has particular value in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Get-column-names-that-has-particular-value/m-p/345665#M59619</link>
    <description>&lt;P&gt;My read of the initial input is that more than 1 column on a given row may have a value of 1.&amp;nbsp; If that is not the case, the following 2 scripts are not the method to use.&lt;/P&gt;
&lt;P&gt;Here is one way to do this&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

// Create a sample data table
dt = New Table( "Example",
	Add Rows( 2 ),
	New Column( "IMCO", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 0] ) ),
	New Column( "IMC1", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 0] ) ),
	New Column( "IIMC2", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 0] ) ),
	New Column( "IMC3", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 0] ) ),
	New Column( "IMC4", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [1, 0] ) ),
	New Column( "IMC5", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 0] ) ),
	New Column( "IMC6", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 1] ), Set Display Width( 46 ) ),
	New Column( "IMC7", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 0] ) ),
	New Column( "IMC8", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 0] ) ),
	New Column( "IMC9", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 0] ) ),
	New Column( "IMC10", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 0] ) ),
	New Column( "IMC11", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 0] ) ),
	New Column( "RESIDUAL", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [32.3201037, 20.54947] ) ),
	New Column( "TEST", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [., .] ) )
);

// Generate a list of columns to be processed
colNamesList = dt &amp;lt;&amp;lt; get column names(string);
remove from (colNamesList,13,2);

// Find the maximum( the ones ) for the columns in question
dtSum = dt&amp;lt;&amp;lt; Summary(
	Max(colNamesList),
	Freq( "None" ),
	Weight( "None" ),
	statistics column name format( "column" ),
	Link to original data table( 0 )
);

// Stack all of the summarized columns
dtStack = dtSum &amp;lt;&amp;lt; Stack(
	columns(
		colNamesList
	),
	Source Label Column( "IMC" ),
	Stacked Data Column( "Data" )
);

close( dtSum, nosave );

// Delete all data that do not have 1 
dtStack &amp;lt;&amp;lt; select where(:Data !=1 );
dtStack &amp;lt;&amp;lt; delete rows;

// Delete the unwanted columns from the summary table
dtStack &amp;lt;&amp;lt; delete columns( {N Rows, data} );

// If there are more rows than in the original table, add rows
if( n rows( dt ) &amp;lt; N Rows( dtStack ),
	dt &amp;lt;&amp;lt; add rows( N Rows( dtStack ) - N Rows( dt ) )
);

// Add the column names for the columns found with 1's in their data
dt &amp;lt;&amp;lt; Update( With( dtStack ) );

close( dtStack, nosave );





&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="imc.PNG" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/29212i78A6FAF15000447F/image-size/large?v=v2&amp;amp;px=999" role="button" title="imc.PNG" alt="imc.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Here is a second way to do it:&amp;nbsp; In this example more than one column on a given row has a value of 1&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

// Create a sample data table
dt = New Table( "Example",
	Add Rows( 2 ),
	New Column( "IMCO", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 0] ) ),
	New Column( "IMC1", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [1, 0] ) ),
	New Column( "IIMC2", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 0] ) ),
	New Column( "IMC3", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 1] ) ),
	New Column( "IMC4", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [1, 0] ) ),
	New Column( "IMC5", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 0] ) ),
	New Column( "IMC6", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 1] ), Set Display Width( 46 ) ),
	New Column( "IMC7", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 0] ) ),
	New Column( "IMC8", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 0] ) ),
	New Column( "IMC9", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 0] ) ),
	New Column( "IMC10", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 0] ) ),
	New Column( "IMC11", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 0] ) ),
	New Column( "RESIDUAL", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [32.3201037, 20.54947] ) ),
	New Column( "TEST", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [., .] ) ),
	New Column( "IMC", Character, "Nominal", Set Values( {"IMC1", "IMC3"} ) )
);

// Generate a list of columns to be processed
colNamesList = dt &amp;lt;&amp;lt; get column names( string );
Remove From( colNamesList, 13, 2 );
foundNamesList = {};

For( i = 1, i &amp;lt;= N Items( colNamesList ), i++,
	theRows = dt &amp;lt;&amp;lt; get rows where( As Column( colNamesList[i] ) == 1 );
	If( N Rows( theRows ) &amp;gt; 0,
		Insert Into( foundNamesList, colNamesList[i] )
	);
);

dt &amp;lt;&amp;lt; New Column( "IMC", character );

// If there are more rows than in the original table, add rows
If( N Rows( dt ) &amp;lt; N Items( foundNamesList ),
	dt &amp;lt;&amp;lt; add rows( N Items( foundNamesList ) - N Rows( dt ) )
);

If( N Items( foundNamesList ) &amp;gt; 0,
	dt:IMC &amp;lt;&amp;lt; set values( foundNamesList )
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;CODE class=" language-jsl"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="imc2.PNG" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/29216i6C479FFB8A888876/image-size/large?v=v2&amp;amp;px=999" role="button" title="imc2.PNG" alt="imc2.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 05 Jan 2021 09:19:42 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2021-01-05T09:19:42Z</dc:date>
    <item>
      <title>Get column names that has particular value</title>
      <link>https://community.jmp.com/t5/Discussions/Get-column-names-that-has-particular-value/m-p/345584#M59614</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I just started using jmp at work and trying to learn JSL. I am trying to write a script to get the column names where the row value =1. For example, the table shows values of 0 and 1 under different IMCX columns and I want to find out which column has the value =1 in each row and store under a new column called IMC. In the first row,&amp;nbsp; column IMC 4 has 1 so I manually enter IMC4 under IMC. There are more than 5000 rows in the tables. Thank you for the help.&amp;nbsp;&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="Paul06_0-1609807451271.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/29193i43AA8EDA732E4DC3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Paul06_0-1609807451271.png" alt="Paul06_0-1609807451271.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 10 Jun 2023 23:24:38 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Get-column-names-that-has-particular-value/m-p/345584#M59614</guid>
      <dc:creator>Paul06</dc:creator>
      <dc:date>2023-06-10T23:24:38Z</dc:date>
    </item>
    <item>
      <title>Re: Get column names that has particular value</title>
      <link>https://community.jmp.com/t5/Discussions/Get-column-names-that-has-particular-value/m-p/345629#M59615</link>
      <description>&lt;P&gt;You can do somthing like this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 348px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/29198i2611148009D122CD/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The formula in Result column is as below:&lt;/P&gt;&lt;PRE&gt;If( :A == 0,
	"",
	Char( Column Name( 1 ) )
) || If( :B == 0,
	"",
	Char( Column Name( 2 ) )
) || If( :C == 0,
	"",
	Char( Column Name( 3 ) )
) || If( :D == 0,
	"",
	Char( Column Name( 4 ) )
)&lt;/PRE&gt;&lt;P&gt;I use &lt;U&gt;&lt;STRONG&gt;concatenate&lt;/STRONG&gt; &lt;/U&gt;keyword to check each column to see if it's a 1.&lt;/P&gt;&lt;P&gt;Let me know if it works out for you!&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jan 2021 02:35:12 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Get-column-names-that-has-particular-value/m-p/345629#M59615</guid>
      <dc:creator>ThuongLe</dc:creator>
      <dc:date>2021-01-05T02:35:12Z</dc:date>
    </item>
    <item>
      <title>Re: Get column names that has particular value</title>
      <link>https://community.jmp.com/t5/Discussions/Get-column-names-that-has-particular-value/m-p/345665#M59619</link>
      <description>&lt;P&gt;My read of the initial input is that more than 1 column on a given row may have a value of 1.&amp;nbsp; If that is not the case, the following 2 scripts are not the method to use.&lt;/P&gt;
&lt;P&gt;Here is one way to do this&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

// Create a sample data table
dt = New Table( "Example",
	Add Rows( 2 ),
	New Column( "IMCO", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 0] ) ),
	New Column( "IMC1", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 0] ) ),
	New Column( "IIMC2", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 0] ) ),
	New Column( "IMC3", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 0] ) ),
	New Column( "IMC4", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [1, 0] ) ),
	New Column( "IMC5", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 0] ) ),
	New Column( "IMC6", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 1] ), Set Display Width( 46 ) ),
	New Column( "IMC7", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 0] ) ),
	New Column( "IMC8", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 0] ) ),
	New Column( "IMC9", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 0] ) ),
	New Column( "IMC10", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 0] ) ),
	New Column( "IMC11", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 0] ) ),
	New Column( "RESIDUAL", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [32.3201037, 20.54947] ) ),
	New Column( "TEST", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [., .] ) )
);

// Generate a list of columns to be processed
colNamesList = dt &amp;lt;&amp;lt; get column names(string);
remove from (colNamesList,13,2);

// Find the maximum( the ones ) for the columns in question
dtSum = dt&amp;lt;&amp;lt; Summary(
	Max(colNamesList),
	Freq( "None" ),
	Weight( "None" ),
	statistics column name format( "column" ),
	Link to original data table( 0 )
);

// Stack all of the summarized columns
dtStack = dtSum &amp;lt;&amp;lt; Stack(
	columns(
		colNamesList
	),
	Source Label Column( "IMC" ),
	Stacked Data Column( "Data" )
);

close( dtSum, nosave );

// Delete all data that do not have 1 
dtStack &amp;lt;&amp;lt; select where(:Data !=1 );
dtStack &amp;lt;&amp;lt; delete rows;

// Delete the unwanted columns from the summary table
dtStack &amp;lt;&amp;lt; delete columns( {N Rows, data} );

// If there are more rows than in the original table, add rows
if( n rows( dt ) &amp;lt; N Rows( dtStack ),
	dt &amp;lt;&amp;lt; add rows( N Rows( dtStack ) - N Rows( dt ) )
);

// Add the column names for the columns found with 1's in their data
dt &amp;lt;&amp;lt; Update( With( dtStack ) );

close( dtStack, nosave );





&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="imc.PNG" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/29212i78A6FAF15000447F/image-size/large?v=v2&amp;amp;px=999" role="button" title="imc.PNG" alt="imc.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Here is a second way to do it:&amp;nbsp; In this example more than one column on a given row has a value of 1&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

// Create a sample data table
dt = New Table( "Example",
	Add Rows( 2 ),
	New Column( "IMCO", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 0] ) ),
	New Column( "IMC1", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [1, 0] ) ),
	New Column( "IIMC2", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 0] ) ),
	New Column( "IMC3", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 1] ) ),
	New Column( "IMC4", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [1, 0] ) ),
	New Column( "IMC5", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 0] ) ),
	New Column( "IMC6", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 1] ), Set Display Width( 46 ) ),
	New Column( "IMC7", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 0] ) ),
	New Column( "IMC8", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 0] ) ),
	New Column( "IMC9", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 0] ) ),
	New Column( "IMC10", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 0] ) ),
	New Column( "IMC11", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 0] ) ),
	New Column( "RESIDUAL", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [32.3201037, 20.54947] ) ),
	New Column( "TEST", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [., .] ) ),
	New Column( "IMC", Character, "Nominal", Set Values( {"IMC1", "IMC3"} ) )
);

// Generate a list of columns to be processed
colNamesList = dt &amp;lt;&amp;lt; get column names( string );
Remove From( colNamesList, 13, 2 );
foundNamesList = {};

For( i = 1, i &amp;lt;= N Items( colNamesList ), i++,
	theRows = dt &amp;lt;&amp;lt; get rows where( As Column( colNamesList[i] ) == 1 );
	If( N Rows( theRows ) &amp;gt; 0,
		Insert Into( foundNamesList, colNamesList[i] )
	);
);

dt &amp;lt;&amp;lt; New Column( "IMC", character );

// If there are more rows than in the original table, add rows
If( N Rows( dt ) &amp;lt; N Items( foundNamesList ),
	dt &amp;lt;&amp;lt; add rows( N Items( foundNamesList ) - N Rows( dt ) )
);

If( N Items( foundNamesList ) &amp;gt; 0,
	dt:IMC &amp;lt;&amp;lt; set values( foundNamesList )
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;CODE class=" language-jsl"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="imc2.PNG" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/29216i6C479FFB8A888876/image-size/large?v=v2&amp;amp;px=999" role="button" title="imc2.PNG" alt="imc2.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jan 2021 09:19:42 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Get-column-names-that-has-particular-value/m-p/345665#M59619</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2021-01-05T09:19:42Z</dc:date>
    </item>
    <item>
      <title>Re: Get column names that has particular value</title>
      <link>https://community.jmp.com/t5/Discussions/Get-column-names-that-has-particular-value/m-p/345697#M59626</link>
      <description>&lt;P&gt;My solution (using same sample data table as txnelson):&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

// Create a sample data table
dt = New Table( "Example",
	Add Rows( 2 ),
	New Column( "IMCO", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 0] ) ),
	New Column( "IMC1", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 0] ) ),
	New Column( "IIMC2", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 0] ) ),
	New Column( "IMC3", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 0] ) ),
	New Column( "IMC4", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [1, 0] ) ),
	New Column( "IMC5", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 0] ) ),
	New Column( "IMC6", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 1] ), Set Display Width( 46 ) ),
	New Column( "IMC7", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 0] ) ),
	New Column( "IMC8", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 0] ) ),
	New Column( "IMC9", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 0] ) ),
	New Column( "IMC10", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 0] ) ),
	New Column( "IMC11", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 0] ) ),
	New Column( "RESIDUAL", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [32.3201037, 20.54947] ) ),
	New Column( "TEST", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [., .] ) )
);

//get wanted columns. Assumes that IMC columns start from column 1 and all IMC columns are one after another
colNames = dt &amp;lt;&amp;lt; Get Column Names("String");
For(i = N Items(colNames), i &amp;gt; 0 , i--,
	If(!Starts With(colNames[i], "IMC"),
		Remove From(colNames, i),
		break(); //we can break on first occurance
	);
);

//new column with IMC with value 1
dt &amp;lt;&amp;lt; New Column("IMC", Character, 
	&amp;lt;&amp;lt; Set Each Value(
		rowValues = dt[Row(), 0][1::N Items(colNames)]; //get values of row as matrix
		colIndex = Contains(rowValues, 1); //get index of
		If(colIndex &amp;gt; 0, //handle 
			colNames[colIndex], //get column name with the index
			""; //when no 1 found use ""
		);
	);
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I like the first solution &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2687"&gt;@txnelson&lt;/a&gt;&amp;nbsp; offered due to two (three) reasons:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;It is using so many menu items directly found from JMP and you could &lt;STRONG&gt;almost&lt;/STRONG&gt; script it without any JSL knowledge by just copy-pasting from datatable Sources&lt;/LI&gt;&lt;LI&gt;It is using very JSL like syntax with all &lt;EM&gt;&amp;lt;&amp;lt; select wheres&lt;/EM&gt; and such&lt;/LI&gt;&lt;LI&gt;(I think that kind of workflow presented in the solution is very JMP like)&lt;/LI&gt;&lt;/OL&gt;</description>
      <pubDate>Tue, 05 Jan 2021 07:47:46 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Get-column-names-that-has-particular-value/m-p/345697#M59626</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2021-01-05T07:47:46Z</dc:date>
    </item>
    <item>
      <title>Re: Get column names that has particular value</title>
      <link>https://community.jmp.com/t5/Discussions/Get-column-names-that-has-particular-value/m-p/345724#M59630</link>
      <description>&lt;P&gt;Regarding "&lt;SPAN&gt;I just started using jmp at work and trying to learn JSL&lt;/SPAN&gt;" (and has been implied already) there are many ways to get the job done.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, in this spirit, please find yet another slight variation. Use 'Help &amp;gt; Books &amp;gt; Scripting Guide' to figure out how it works.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

// Create a sample data table
dt = New Table( "Example",
	Add Rows( 2 ),
	New Column( "IMCO", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 0] ) ),
	New Column( "IMC1", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [1, 0] ) ),
	New Column( "IIMC2", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 0] ) ),
	New Column( "IMC3", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 1] ) ),
	New Column( "IMC4", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [1, 0] ) ),
	New Column( "IMC5", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 0] ) ),
	New Column( "IMC6", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 1] ), Set Display Width( 46 ) ),
	New Column( "IMC7", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 0] ) ),
	New Column( "IMC8", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 0] ) ),
	New Column( "IMC9", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 0] ) ),
	New Column( "IMC10", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 0] ) ),
	New Column( "IMC11", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 0] ) ),
);

// Get a list of the column names
colList = dt &amp;lt;&amp;lt; getColumnNames("String");

// Get the '0's and '1's into a matrix
mat = dt &amp;lt;&amp;lt; getAsMatrix;

// Value to search for
searchVal = 1;

// Add an 'expression' column and loop rowise . . .
newCol = dt &amp;lt;&amp;lt; NewColumn("Value "||Char(searchVal)||" found in Column:", Expression);
for (r=1, r&amp;lt;=NRow(dt), r++,
	newCol[r] = colList[Loc(mat[r, 0], searchVal)];
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jan 2021 11:52:15 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Get-column-names-that-has-particular-value/m-p/345724#M59630</guid>
      <dc:creator>ian_jmp</dc:creator>
      <dc:date>2021-01-05T11:52:15Z</dc:date>
    </item>
    <item>
      <title>Re: Get column names that has particular value</title>
      <link>https://community.jmp.com/t5/Discussions/Get-column-names-that-has-particular-value/m-p/345750#M59641</link>
      <description>Thank you so much. It worked!</description>
      <pubDate>Tue, 05 Jan 2021 16:13:48 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Get-column-names-that-has-particular-value/m-p/345750#M59641</guid>
      <dc:creator>Paul06</dc:creator>
      <dc:date>2021-01-05T16:13:48Z</dc:date>
    </item>
    <item>
      <title>Re: Get column names that has particular value</title>
      <link>https://community.jmp.com/t5/Discussions/Get-column-names-that-has-particular-value/m-p/345751#M59642</link>
      <description>Thanks you for your time and help. I am sorry I did not state the problem clearly. In each row, there is only one instance of 1 under a column and I need to pick out the column name and save under a new column.</description>
      <pubDate>Tue, 05 Jan 2021 16:16:07 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Get-column-names-that-has-particular-value/m-p/345751#M59642</guid>
      <dc:creator>Paul06</dc:creator>
      <dc:date>2021-01-05T16:16:07Z</dc:date>
    </item>
    <item>
      <title>Re: Get column names that has particular value</title>
      <link>https://community.jmp.com/t5/Discussions/Get-column-names-that-has-particular-value/m-p/345771#M59644</link>
      <description>Hi Ian, Thanks for your time and explanation. I can understand your code. However, when I ran the script setting dt as current table, I got empty() in the resultant expression column. I have a long way to learn here. Thanks all for your input and suggestions</description>
      <pubDate>Tue, 05 Jan 2021 16:21:54 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Get-column-names-that-has-particular-value/m-p/345771#M59644</guid>
      <dc:creator>Paul06</dc:creator>
      <dc:date>2021-01-05T16:21:54Z</dc:date>
    </item>
    <item>
      <title>Re: Get column names that has particular value</title>
      <link>https://community.jmp.com/t5/Discussions/Get-column-names-that-has-particular-value/m-p/345772#M59645</link>
      <description>Thank you for your time and help. I was not able to run the script succesfully. It created a column IMC but no value in it. I will debug and try to understand the code better.</description>
      <pubDate>Tue, 05 Jan 2021 16:23:40 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Get-column-names-that-has-particular-value/m-p/345772#M59645</guid>
      <dc:creator>Paul06</dc:creator>
      <dc:date>2021-01-05T16:23:40Z</dc:date>
    </item>
    <item>
      <title>Re: Get column names that has particular value</title>
      <link>https://community.jmp.com/t5/Discussions/Get-column-names-that-has-particular-value/m-p/345847#M59652</link>
      <description>&lt;P&gt;Hi Ian,&lt;BR /&gt;Spend some time reading the help&amp;gt;Books section and changed the keyword from loc to contains worked now. Thank you ton!&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// Get a list of the column names
colList = dt &amp;lt;&amp;lt; getColumnNames( "String" );

// Get the '0's and '1's into a matrix
mat = dt &amp;lt;&amp;lt; getAsMatrix;

// Value to search for
searchVal = 1;

// Add an 'expression' column and loop rowise . . .
newCol = dt &amp;lt;&amp;lt; New Column( "Value " || Char( searchVal ) || " found in Column:", Expression );
for( r = 1, r &amp;lt;= N Row( dt ), r++,
    newCol[r] = colList[Contains( mat[r, 0], searchVal )]
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Jan 2021 20:08:18 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Get-column-names-that-has-particular-value/m-p/345847#M59652</guid>
      <dc:creator>Paul06</dc:creator>
      <dc:date>2021-01-05T20:08:18Z</dc:date>
    </item>
    <item>
      <title>Re: Get column names that has particular value</title>
      <link>https://community.jmp.com/t5/Discussions/Get-column-names-that-has-particular-value/m-p/766799#M94680</link>
      <description>&lt;P&gt;Hi jthi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if my data looks like this example but all of the columns are numeric (continuous data) and I want to choose the column name with cut off such as &amp;gt; 3000 (in 1 row might have multiple columns &amp;gt; 3000) what should I do on script?&lt;BR /&gt;I use the following script&lt;/P&gt;&lt;P class=""&gt;colNames = dt &amp;lt;&amp;lt; &lt;SPAN class=""&gt;Get Column Names&lt;/SPAN&gt;(&lt;SPAN class=""&gt;"String"&lt;/SPAN&gt;);&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;For&lt;/SPAN&gt;(i = &lt;SPAN class=""&gt;N Items&lt;/SPAN&gt;(colNames), i &amp;gt; &lt;SPAN class=""&gt;3000 &lt;/SPAN&gt;, i--,&lt;/P&gt;&lt;P class=""&gt;);&lt;/P&gt;&lt;P class=""&gt;but it did not work.&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;Best&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jun 2024 14:28:18 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Get-column-names-that-has-particular-value/m-p/766799#M94680</guid>
      <dc:creator>doraemengs</dc:creator>
      <dc:date>2024-06-18T14:28:18Z</dc:date>
    </item>
  </channel>
</rss>

