Ciao, Below is sample data.

Code:
clear
input STUDENT GRADELEVEL STATUS WANT
1 10 0 0
1 10 0 0
1 10 1 1
1 10 0 1
2 9 1 1
2 9 1 1
2 9 0 1
2 9 2 2
3 11 1 1
3 11 0 1
3 11 2 2
3 11 1 2
4 8 2 2
4 8 0 2
4 8 0 2
4 8 0 2
end

I have the STUDENT, GRADELEVEL, STATUS columns. I hope to create the WANT column. As shown, the WANT column depends on the STATUS column and updates. STATUS takes on the maximum value of WANT when it occurs and then fills down the rest of the way. Basically 0 = did not take test; 1 = failed test; 2 = passed test. There are some clerical data entry errors. So ultimately I want to carry forward the 2 when it occurs and the 1 when it occurs; but 2 is the ultimate carry forward goal.