Hello,
I am new to JMP scripting and have been trying to write a script for a specific process given a data table to work with. To help explain what I want, here is a crude sample table.

What I want to do is to write a script that would iteratively check each row in the "Step Name" column for the value "Sleep". When it gets to a row with "Sleep", it will then check the corresponding value under the column "Speed". Then, I want the script to check all of the previous rows that share the same values under the "Speed" column. While it shares the same value under the "Speed" column, it will then check for existing values under the "Material" column. If a value exists under "Material", it will take that value and the corresponding value under "Speed" and output them in a new table, like this:

I have an idea that this would require an extensive For loop, but I don't know how to approach it. I would greatly appreciate any suggestions on how to write this script. Thank you