Help using for loop and conditional to fill in missing values
Sep 19, 2018 6:25 AM(2826 views)
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();
if( :workorder == lag(:workorder,1)& is missing(:yield),:yield= lag(:yield,1),:yield)