<?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 question: select columns and replace missing values with zero in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/JSL-question-select-columns-and-replace-missing-values-with-zero/m-p/36590#M21491</link>
    <description>Thanks. But in your method you still replace missing values in all columns. What I am trying to do is: say there are 10 numeric columns, and all of them have missing values. But I only want to replace missing values in certain columns ("A" and "B" in my example). That's why in my original message I used col_list = {"A","B"}, but for some reason that doesn't work....</description>
    <pubDate>Wed, 01 Mar 2017 18:02:30 GMT</pubDate>
    <dc:creator>pomemelom</dc:creator>
    <dc:date>2017-03-01T18:02:30Z</dc:date>
    <item>
      <title>JSL question: select columns and replace missing values with zero</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-question-select-columns-and-replace-missing-values-with-zero/m-p/36587#M21488</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are many numeric columns in the data table, and all of them have missing values in them.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to select only few of them (considering that I know the column names already), and replace the missing values in them with zero.&lt;/P&gt;&lt;P&gt;I wrote the code as follows, but it doesn't work.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you help?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;dt = data table("Untitled 9");
col_list = {"A","B"};
For( i = 1, i &amp;lt;= N Items( col_list ), i++,
  col_list[i][dt &amp;lt;&amp;lt; get rows where( Is Missing( col_list[i][]) )] = 0);&lt;/PRE&gt;</description>
      <pubDate>Wed, 01 Mar 2017 17:50:35 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-question-select-columns-and-replace-missing-values-with-zero/m-p/36587#M21488</guid>
      <dc:creator>pomemelom</dc:creator>
      <dc:date>2017-03-01T17:50:35Z</dc:date>
    </item>
    <item>
      <title>Re: JSL question: select columns and replace missing values with zero</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-question-select-columns-and-replace-missing-values-with-zero/m-p/36589#M21490</link>
      <description>&lt;P&gt;Here's one way to do it:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;dt = New Table( "Test Zeroes",	Add Rows( 3 ),
	New Column( "Column 1", Character, "Nominal", Set Values( {"a", "b", "c"} ) ),
	New Column( "Column 2",	Numeric, "Continuous", Format( "Best", 12 ),
		Set Values( [1, ., 3] ) ),
	New Column( "Column 3", Numeric, "Continuous", Format( "Best", 12 ),
		Set Values( [., 2, .] ) )
);

col_list = dt &amp;lt;&amp;lt; get column names(string, numeric);

For( i = 1, i &amp;lt;= N Items( col_list ), i++,
	missing_rows = dt &amp;lt;&amp;lt; get rows where (is missing(as column(dt, col_list[i])));

	if (nrows(missing_rows) &amp;gt; 0,
		column(dt, col_list[i])[missing_rows] = 0;
	);
);&lt;/PRE&gt;</description>
      <pubDate>Wed, 01 Mar 2017 17:51:54 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-question-select-columns-and-replace-missing-values-with-zero/m-p/36589#M21490</guid>
      <dc:creator>pmroz</dc:creator>
      <dc:date>2017-03-01T17:51:54Z</dc:date>
    </item>
    <item>
      <title>Re: JSL question: select columns and replace missing values with zero</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-question-select-columns-and-replace-missing-values-with-zero/m-p/36590#M21491</link>
      <description>Thanks. But in your method you still replace missing values in all columns. What I am trying to do is: say there are 10 numeric columns, and all of them have missing values. But I only want to replace missing values in certain columns ("A" and "B" in my example). That's why in my original message I used col_list = {"A","B"}, but for some reason that doesn't work....</description>
      <pubDate>Wed, 01 Mar 2017 18:02:30 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-question-select-columns-and-replace-missing-values-with-zero/m-p/36590#M21491</guid>
      <dc:creator>pomemelom</dc:creator>
      <dc:date>2017-03-01T18:02:30Z</dc:date>
    </item>
    <item>
      <title>Re: JSL question: select columns and replace missing values with zero</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-question-select-columns-and-replace-missing-values-with-zero/m-p/36591#M21492</link>
      <description>&lt;P&gt;My method will replace missing values in all &lt;U&gt;numeric&lt;/U&gt; columns. &amp;nbsp;If you just want to replace values in your specific list, just provide&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;col_list = {"A", "B"}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;in place of my definition of col_list.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Mar 2017 18:05:47 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-question-select-columns-and-replace-missing-values-with-zero/m-p/36591#M21492</guid>
      <dc:creator>pmroz</dc:creator>
      <dc:date>2017-03-01T18:05:47Z</dc:date>
    </item>
    <item>
      <title>Re: JSL question: select columns and replace missing values with zero</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-question-select-columns-and-replace-missing-values-with-zero/m-p/36628#M21511</link>
      <description>&lt;P&gt;I used in the past the search/replace option:&lt;/P&gt;&lt;P&gt;Select the column you want to replace missing by zero&lt;/P&gt;&lt;P&gt;Search for . and replace by 0, be sure to check the "search only in selected column" option.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Mar 2017 21:53:05 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-question-select-columns-and-replace-missing-values-with-zero/m-p/36628#M21511</guid>
      <dc:creator>r23426</dc:creator>
      <dc:date>2017-03-01T21:53:05Z</dc:date>
    </item>
  </channel>
</rss>

