Hi all,
I am working with a excel data set where multiple rows (batches) are merged for a single workorder and a single yield. Once in JMP, the merge cells split and every row but the yield and scrap column are populated with the correct values for each work order.
I need to populate the missing values with the yield value for that work order. I have attached a example data table.
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.
// example of populating missing values with new column
dt << new column("test", numeric, continuous, set each value(if( :WorkOrder == lag(:WorkOrder,1)& is missing(:yield),:yield= lag(:yield,1),:yield)));My first thought was to use a for loop 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?
dt = current data table();
n=nrows(dt);
for(i=0,i<=n, i++,
if( :workorder == lag(:workorder,1)& is missing(:yield),:yield= lag(:yield,1),:yield)
);
Thank you very much, that works perfectly.
In a script, using a For() loop, you need to specify the row by using a subscript. See below
Names Default To Here( 1 );
dt = Current Data Table();
For( i = 2, i <= N Rows( dt ), i++,
If( :workorder[i] == :workorder[i - 1] & Is Missing( :yield[i] ),
:yield[i] = :yield[i - 1]
)
);