Hi everyone,
I'm trying to create a column which evaluates it's previous row and adds the zscore to it and then takes the maximum between this evaluation and 0. I've tried moving the lag formula around the Cumulative Sum equation but have not had any luck. It is only taking the value of zscore regardless of the previous row. Any help on how to resolve this would be greatly appreciated!
dt = Open("Big Class.jmp");
dt << New Column( "zscore", Formula((:weight - Col Mean( :weight, :sex )) / Col Std Dev( :weight, :sex )));
dt << Sort( By( :sex), Order( Ascending), Replace Table );
dt << New Column( "S_Hi", Formula( If( :sex == Lag( :sex ), Max( 0, :zscore + Lag( Col Cumulative Sum( :S_Hi ) ) ), Max( 0, :zscore ) ) ) )