<?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 JMP Script : to copy the non empty value  from multiple column to  new column in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/JMP-Script-to-copy-the-non-empty-value-from-multiple-column-to/m-p/426270#M67610</link>
    <description>&lt;P&gt;Hi Team,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Currently using JMP15 ,&lt;BR /&gt;need help in copying the non empty value from mutiple column to a different columns,&lt;/P&gt;&lt;P&gt;not sure i explained issue correctly below is what i am looking for&lt;/P&gt;&lt;P&gt;Here the column name and count is variable&lt;/P&gt;&lt;P&gt;and each row will have only 2 column with value also&lt;/P&gt;&lt;P&gt;Input:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jinsejoseph_0-1634199200974.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/36556i335D787D1BB4E8C9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jinsejoseph_0-1634199200974.png" alt="jinsejoseph_0-1634199200974.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Expected out put&lt;/P&gt;&lt;P&gt;Column1 and column2 are the output column&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jinsejoseph_1-1634199380574.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/36557i92887363EE1E404C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jinsejoseph_1-1634199380574.png" alt="jinsejoseph_1-1634199380574.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 10 Jun 2023 23:38:27 GMT</pubDate>
    <dc:creator>jinsejoseph</dc:creator>
    <dc:date>2023-06-10T23:38:27Z</dc:date>
    <item>
      <title>JMP Script : to copy the non empty value  from multiple column to  new column</title>
      <link>https://community.jmp.com/t5/Discussions/JMP-Script-to-copy-the-non-empty-value-from-multiple-column-to/m-p/426270#M67610</link>
      <description>&lt;P&gt;Hi Team,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Currently using JMP15 ,&lt;BR /&gt;need help in copying the non empty value from mutiple column to a different columns,&lt;/P&gt;&lt;P&gt;not sure i explained issue correctly below is what i am looking for&lt;/P&gt;&lt;P&gt;Here the column name and count is variable&lt;/P&gt;&lt;P&gt;and each row will have only 2 column with value also&lt;/P&gt;&lt;P&gt;Input:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jinsejoseph_0-1634199200974.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/36556i335D787D1BB4E8C9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jinsejoseph_0-1634199200974.png" alt="jinsejoseph_0-1634199200974.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Expected out put&lt;/P&gt;&lt;P&gt;Column1 and column2 are the output column&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jinsejoseph_1-1634199380574.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/36557i92887363EE1E404C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jinsejoseph_1-1634199380574.png" alt="jinsejoseph_1-1634199380574.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 10 Jun 2023 23:38:27 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JMP-Script-to-copy-the-non-empty-value-from-multiple-column-to/m-p/426270#M67610</guid>
      <dc:creator>jinsejoseph</dc:creator>
      <dc:date>2023-06-10T23:38:27Z</dc:date>
    </item>
    <item>
      <title>Re: JMP Script : to copy the non empty value  from multiple column to  new column</title>
      <link>https://community.jmp.com/t5/Discussions/JMP-Script-to-copy-the-non-empty-value-from-multiple-column-to/m-p/426304#M67614</link>
      <description>&lt;P&gt;Here are a couple of solutions, both of which are modifications of my responses to your previous discussion.&lt;/P&gt;
&lt;P&gt;The Loc() function works with missing values, just as it does with zeros.&amp;nbsp; So the following hard wired JSL works.&amp;nbsp; The difference is that the Delta is not being produced.&amp;nbsp; Instead, the first value is being extracted for Column 12 and the second for Column 13&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Current Data Table();

dt &amp;lt;&amp;lt; New Column( "Column 12",
	Formula(
		x = :data[Row()] || :data1[Row()] || :data2[Row()] || :data3[Row()] || :data4[Row()] ||
		:data5[Row()] || :data6[Row()] || :data7[Row()] || :data8[Row()] || :data9[Row()];
		y = Loc( x );
		Try( x[y[1]], . );
	)
);

dt &amp;lt;&amp;lt; New Column( "Column 13",
	Formula(
		x = :data[Row()] || :data1[Row()] || :data2[Row()] || :data3[Row()] || :data4[Row()] ||
		:data5[Row()] || :data6[Row()] || :data7[Row()] || :data8[Row()] || :data9[Row()];
		y = Loc( x );
		Try( x[y[2]], . );
	)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;To expand this to the situation where the column names are not known, and the number of columns might be different, the below code will work&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Current Data Table();

// Get the columns
colNames = dt &amp;lt;&amp;lt; get column names( string, continuous );

// Build the first column and formula
theExpr = "dt&amp;lt;&amp;lt;new column(\!"Column 12\!",formula(x = " || colNames[1] || "[Row()]";
For( i = 2, i &amp;lt;= N Items( colNames ), i++,
	theExpr = theExpr || " || " || colNames[i] || "[Row()]"
);
theExpr = theExpr || 
";y = Loc( x );
Try( x[y[1]], . );";

// Execute the Created JSL
Eval( Parse( theExpr ) );

// Build the second column and formula
theExpr = "dt&amp;lt;&amp;lt;new column(\!"Column 13\!",formula(x = " || colNames[1] || "[Row()]";
For( i = 2, i &amp;lt;= N Items( colNames ), i++,
	theExpr = theExpr || " || " || colNames[i] || "[Row()]"
);
theExpr = theExpr || 
";y = Loc( x );
Try( x[y[2]], . );";

// Execute the Created JSL
Eval( Parse( theExpr ) );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 14 Oct 2021 09:10:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JMP-Script-to-copy-the-non-empty-value-from-multiple-column-to/m-p/426304#M67614</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2021-10-14T09:10:09Z</dc:date>
    </item>
    <item>
      <title>Re: JMP Script : to copy the non empty value  from multiple column to  new column</title>
      <link>https://community.jmp.com/t5/Discussions/JMP-Script-to-copy-the-non-empty-value-from-multiple-column-to/m-p/426370#M67620</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/32844"&gt;@jinsejoseph&lt;/a&gt; ,&lt;/P&gt;
&lt;P&gt;building on &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2687"&gt;@txnelson&lt;/a&gt; s approach there may be a shorthand script using some built in features. this was achieved by maximum clicking and minimum generalization of the script.&lt;/P&gt;
&lt;P&gt;this approach uses the two commands: Combine and Text to column. combine has the advantage that it ignores missing values. in this case it is used as concatenate without missing values.&lt;/P&gt;
&lt;P&gt;then, text to columns comes in hand when we want the final data in separate columns.&lt;/P&gt;
&lt;P&gt;please do let us know if it works or needs further generalization for your purposes.&lt;/P&gt;
&lt;P&gt;ron&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = New Table( "original data set",
	Add Rows( 36 ),
	New Column( "Data 01",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [1, 1, 1, ., ., ., ., ., ., ., ., ., ., ., ., 11, 11, 11, ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., .] )
	),
	New Column( "Data 02",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [., ., ., 2, 2, 2, ., ., ., ., ., ., ., ., ., ., ., ., 12, 12, 12, ., ., ., ., ., ., ., ., ., ., ., ., ., ., .] )
	),
	New Column( "Data 03",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [., ., ., ., ., ., 3, 3, 3, ., ., ., ., ., ., ., ., ., ., ., ., 13, 13, 13, ., ., ., ., ., ., ., ., ., ., ., .] )
	),
	New Column( "Data 04",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [., ., ., ., ., ., ., ., ., 4, 4, 4, ., ., ., ., ., ., ., ., ., ., ., ., 14, 14, 14, ., ., ., ., ., ., ., ., .] )
	),
	New Column( "Data 05",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [., ., ., ., ., ., ., ., ., ., ., ., 5, 5, 5, ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., .] ),
		Set Display Width( 59 )
	),
	New Column( "Data 06",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [10, 10, 10, ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., .] )
	),
	New Column( "Data 07",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [., ., ., 20, 20, 20, ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., 200, 200, 200, ., ., ., ., ., ., ., ., .] )
	),
	New Column( "Data 08",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [., ., ., ., ., ., 30, 30, 30, ., ., ., ., ., ., ., ., ., ., ., ., 300, 300, 300, ., ., ., ., ., ., ., ., ., ., ., .] )
	),
	New Column( "Data 09",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [., ., ., ., ., ., ., ., ., 40, 40, 40, ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., .] ),
		Set Display Width( 67 )
	),
	New Column( "Data 10",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [., ., ., ., ., ., ., ., ., ., ., ., 50, 50, 50, ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., .] )
	)
);
// now we get to work
// Get the columns names to combine.
colNames = dt &amp;lt;&amp;lt; get column names( string, continuous );


// Combine columns using list - here is the trick, it ignores missing values
dt &amp;lt;&amp;lt; Combine Columns(
	columns( eval (colNames) ),
	Column Name( "combined" ),
	Delimiter( "," ),
	Multiple Response( 0 )
);

// Text to columns - now we can uncombine the data into as many columns there is actual data. this is robust to any number of events per row.
dt &amp;lt;&amp;lt; Text to Columns(
	columns( :combined ),
	Delimiters( "," )
);


&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 14 Oct 2021 12:22:06 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JMP-Script-to-copy-the-non-empty-value-from-multiple-column-to/m-p/426370#M67620</guid>
      <dc:creator>ron_horne</dc:creator>
      <dc:date>2021-10-14T12:22:06Z</dc:date>
    </item>
  </channel>
</rss>

