BookmarkSubscribeRSS Feed
Choose Language Hide Translation Bar
Highlighted
lburtone
Community Member

Fill empty cells with last valid value

Hello,

 

I have the following problem. My dataset is composed by a list of rows, each representing one item produced by a machine. Normal items are not measured, but from time to time some "measurement items" are produced and the propetries measured. The assumption is that all the parts not measured will have properties similar to the latest measurment. How can I fill the empty cells using this logic?

I attached an example, so that it is easier to understand, the table looks like this:

 

Time      Order                    Test Value        (Expected)
1            Measurement            2.5                     2.5
2            Production                 -                         2.5
3            Production                 -                         2.5
4            Measurement            2                         2
5            Production                 -                         2 
6            Production                 -                         2 
7            Production                 -                         2 
8            Measurement            3                        3
9            Production                 -                         3 
10          Production                 -                         3

 

 

 

0 Kudos
1 ACCEPTED SOLUTION

Accepted Solutions
ron_horne
Super User

Re: Fill empty cells with last valid value

perhaps the following line of script can help:

 

Names Default To Here( 1 );
dt = Current Data Table();
For( i = 2, i <= N Rows( dt ), i++,
	If( Is Missing( :test value[i] ),
		:test value[i] = :test value[i - 1]
	)
);

 

best,

ron

 

2 REPLIES 2
ron_horne
Super User

Re: Fill empty cells with last valid value

perhaps the following line of script can help:

 

Names Default To Here( 1 );
dt = Current Data Table();
For( i = 2, i <= N Rows( dt ), i++,
	If( Is Missing( :test value[i] ),
		:test value[i] = :test value[i - 1]
	)
);

 

best,

ron

 

Byron_JMP
Staff

Re: Fill empty cells with last valid value

Here are a couple of other ideas.

 

https://community.jmp.com/t5/JMP-Scripts/Fill-in-Missing-Cells/ta-p/21700

JMP Systems Engineer, Pharm and BioPharm Sciences