<?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 Select Multiple Columns and Update  Missing Column Value in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Select-Multiple-Columns-and-Update-Missing-Column-Value/m-p/210933#M42238</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am new to JMP scripting. I am working on a script to slelect multiple columns that contain the word "Censor" and update missing value. below is a set of sample data. I've listed three columns Censor A, Censor B, and Censor C. but in real world, the number of columns can be different every time. so I will have to select columns that contain the work " Censor", then update all missing value with "S". Can I do that in JSL? I am stil learning scripting but could not find a way in JMP Help.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Censor A&lt;/TD&gt;&lt;TD&gt;Censor B&lt;/TD&gt;&lt;TD&gt;Censor C&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;F&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;F&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;F&lt;/TD&gt;&lt;TD&gt;F&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;F&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;F&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;F&lt;/TD&gt;&lt;TD&gt;F&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;F&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
    <pubDate>Wed, 29 May 2019 05:21:14 GMT</pubDate>
    <dc:creator>Nata007</dc:creator>
    <dc:date>2019-05-29T05:21:14Z</dc:date>
    <item>
      <title>Select Multiple Columns and Update  Missing Column Value</title>
      <link>https://community.jmp.com/t5/Discussions/Select-Multiple-Columns-and-Update-Missing-Column-Value/m-p/210933#M42238</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am new to JMP scripting. I am working on a script to slelect multiple columns that contain the word "Censor" and update missing value. below is a set of sample data. I've listed three columns Censor A, Censor B, and Censor C. but in real world, the number of columns can be different every time. so I will have to select columns that contain the work " Censor", then update all missing value with "S". Can I do that in JSL? I am stil learning scripting but could not find a way in JMP Help.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Censor A&lt;/TD&gt;&lt;TD&gt;Censor B&lt;/TD&gt;&lt;TD&gt;Censor C&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;F&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;F&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;F&lt;/TD&gt;&lt;TD&gt;F&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;F&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;F&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;F&lt;/TD&gt;&lt;TD&gt;F&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;F&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Wed, 29 May 2019 05:21:14 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Select-Multiple-Columns-and-Update-Missing-Column-Value/m-p/210933#M42238</guid>
      <dc:creator>Nata007</dc:creator>
      <dc:date>2019-05-29T05:21:14Z</dc:date>
    </item>
    <item>
      <title>Re: Select Multiple Columns and Update  Missing Column Value</title>
      <link>https://community.jmp.com/t5/Discussions/Select-Multiple-Columns-and-Update-Missing-Column-Value/m-p/210943#M42239</link>
      <description>&lt;P&gt;Here is a simple script that will accomplish the filling in of the missing cells&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( 6 ),
	New Column( "Censor A",
		Character,
		"Nominal",
		Set Values( {"F", "F", "F", "", "", "F"} )
	),
	New Column( "Censor B",
		Character,
		"Nominal",
		Set Values( {"", "F", "", "", "F", ""} )
	),
	New Column( "Censor C",
		Character,
		"Nominal",
		Set Values( {"F", "", "", "F", "F", ""} )
	)
);

// Get the names of all of the columns
colNames = dt &amp;lt;&amp;lt; get column names( string );

// Loop across all columns and if a Censor column
// then process
For( i = 1, i &amp;lt;= N Items( colNames ), i++,
	If( Left( colNames[i], 6 ) == "Censor",
		dt &amp;lt;&amp;lt; select where( As Column( colNames[i] ) == "" );
		// If blanks are found then process
		If( N Rows( dt &amp;lt;&amp;lt; get selected rows ) &amp;gt; 0,
			As Column( colNames[i] )[dt &amp;lt;&amp;lt; get selected Rows] = "S"
		);
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 29 May 2019 05:48:36 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Select-Multiple-Columns-and-Update-Missing-Column-Value/m-p/210943#M42239</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2019-05-29T05:48:36Z</dc:date>
    </item>
    <item>
      <title>Re: Select Multiple Columns and Update  Missing Column Value</title>
      <link>https://community.jmp.com/t5/Discussions/Select-Multiple-Columns-and-Update-Missing-Column-Value/m-p/210944#M42240</link>
      <description>Thank you!</description>
      <pubDate>Wed, 29 May 2019 05:52:46 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Select-Multiple-Columns-and-Update-Missing-Column-Value/m-p/210944#M42240</guid>
      <dc:creator>Nata007</dc:creator>
      <dc:date>2019-05-29T05:52:46Z</dc:date>
    </item>
    <item>
      <title>Re: Select Multiple Columns and Update  Missing Column Value</title>
      <link>https://community.jmp.com/t5/Discussions/Select-Multiple-Columns-and-Update-Missing-Column-Value/m-p/210945#M42241</link>
      <description>Thanks for your help! Here is another questions. for above case, how do I have update missing value with value in another column?</description>
      <pubDate>Wed, 29 May 2019 05:57:32 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Select-Multiple-Columns-and-Update-Missing-Column-Value/m-p/210945#M42241</guid>
      <dc:creator>Nata007</dc:creator>
      <dc:date>2019-05-29T05:57:32Z</dc:date>
    </item>
    <item>
      <title>Re: Select Multiple Columns and Update  Missing Column Value</title>
      <link>https://community.jmp.com/t5/Discussions/Select-Multiple-Columns-and-Update-Missing-Column-Value/m-p/210957#M42243</link>
      <description>&lt;P&gt;Here is a modification to my initial script to do what I think you want.....&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 2",
	Add Rows( 6 ),
	New Column( "Censor A",
		Character,
		"Nominal",
		Set Values( {"F", "F", "F", "", "", "F"} )
	),
	New Column( "Censor B",
		Character,
		"Nominal",
		Set Values( {"", "F", "", "", "F", ""} )
	),
	New Column( "Censor C",
		Character,
		"Nominal",
		Set Values( {"F", "", "", "F", "F", ""} )
	),
	New Column( "Setting Column",
		Character,
		"Nominal",
		Set Values( {"Z", "X", "Y", "W", "P", "Q"} )
	)
);

// Get the names of all of the columns
colNames = dt &amp;lt;&amp;lt; get column names( string );

// Loop across all columns and if a Censor column
// then process
For( i = 1, i &amp;lt;= N Items( colNames ), i++,
	If( Left( colNames[i], 6 ) == "Censor",
		dt &amp;lt;&amp;lt; select where( As Column( colNames[i] ) == "" );
		// If blanks are found then process
		rowMat = dt &amp;lt;&amp;lt; get selected rows;
		If( N Rows( rowMat ) &amp;gt; 0,
			For( k = 1, k &amp;lt;= N Rows( rowMat ), k++,
				Column( colNames[i] )[rowMat[k]] = :Setting Column[rowMat[k]]
			)
		);
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 29 May 2019 06:10:57 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Select-Multiple-Columns-and-Update-Missing-Column-Value/m-p/210957#M42243</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2019-05-29T06:10:57Z</dc:date>
    </item>
  </channel>
</rss>

