<?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: Help using for loop and conditional to fill in missing values in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Help-using-for-loop-and-conditional-to-fill-in-missing-values/m-p/74166#M35779</link>
    <description>&lt;P&gt;In a script, using a For() loop, you need to specify the row by using a subscript.&amp;nbsp; See below&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Current Data Table();


For( i = 2, i &amp;lt;= N Rows( dt ), i++,
	If( :workorder[i] == :workorder[i - 1] &amp;amp; Is Missing( :yield[i] ),
		:yield[i] = :yield[i - 1]
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 19 Sep 2018 14:03:37 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2018-09-19T14:03:37Z</dc:date>
    <item>
      <title>Help using for loop and conditional to fill in missing values</title>
      <link>https://community.jmp.com/t5/Discussions/Help-using-for-loop-and-conditional-to-fill-in-missing-values/m-p/74163#M35777</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am working with a excel data set where multiple&amp;nbsp;rows (batches)&amp;nbsp;are&amp;nbsp;merged for a single workorder and a single yield. Once in JMP, the merge cells split and&amp;nbsp;every row&amp;nbsp;but the yield and scrap column are populated with the correct values for each work order.&lt;/P&gt;&lt;P&gt;I need to populate the missing values with the yield value for that work order. I have attached a example data table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can do this by creating a new column and using a conditional statement with lag but I would like to do this without a new column.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// example of populating missing values with new column
dt &amp;lt;&amp;lt; new column("test", numeric, continuous, set each value(if( :WorkOrder == lag(:WorkOrder,1)&amp;amp; is missing(:yield),:yield= lag(:yield,1),:yield)));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;My first thought was to use a for loop&amp;nbsp;but I'm having trouble. The script below runs but does not populate any data in place of the missing values. Could someone please suggest a better way to do this?&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = current data table();

n=nrows(dt);
for(i=0,i&amp;lt;=n, i++,
	if( :workorder == lag(:workorder,1)&amp;amp; is missing(:yield),:yield= lag(:yield,1),:yield)
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Consolas" size="2"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Sep 2018 13:25:45 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Help-using-for-loop-and-conditional-to-fill-in-missing-values/m-p/74163#M35777</guid>
      <dc:creator>acfbt</dc:creator>
      <dc:date>2018-09-19T13:25:45Z</dc:date>
    </item>
    <item>
      <title>Re: Help using for loop and conditional to fill in missing values</title>
      <link>https://community.jmp.com/t5/Discussions/Help-using-for-loop-and-conditional-to-fill-in-missing-values/m-p/74166#M35779</link>
      <description>&lt;P&gt;In a script, using a For() loop, you need to specify the row by using a subscript.&amp;nbsp; See below&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Current Data Table();


For( i = 2, i &amp;lt;= N Rows( dt ), i++,
	If( :workorder[i] == :workorder[i - 1] &amp;amp; Is Missing( :yield[i] ),
		:yield[i] = :yield[i - 1]
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Sep 2018 14:03:37 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Help-using-for-loop-and-conditional-to-fill-in-missing-values/m-p/74166#M35779</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2018-09-19T14:03:37Z</dc:date>
    </item>
    <item>
      <title>Re: Help using for loop and conditional to fill in missing values</title>
      <link>https://community.jmp.com/t5/Discussions/Help-using-for-loop-and-conditional-to-fill-in-missing-values/m-p/74237#M35794</link>
      <description>&lt;P&gt;Thank you very much, that works perfectly.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Sep 2018 17:06:28 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Help-using-for-loop-and-conditional-to-fill-in-missing-values/m-p/74237#M35794</guid>
      <dc:creator>acfbt</dc:creator>
      <dc:date>2018-09-19T17:06:28Z</dc:date>
    </item>
  </channel>
</rss>

