Dear Jim:
Thank you, this was so incredibly helpful. I can't thank you enough. Your script worked for me.
I spent the last day trying to figure out how to append to your script. In particular I want to create a 4th category for LAB_VALUE. If a patient's lab value status doesn't meet any of the 3 conditions below, then I'd like to flag it as a fourth category "4".
I tried to add ",4)" to the last if statement, but it wouldn't work. The script editor kept complaining about missing , or ). Or it wouldn't evaluate some of the rows. Any help you can offer would be greatly appreciated.
@txnelson wrote:
Here is one way of setting the values for STATUS. It isn't very efficient code, but it should work. I was not able to fully test it, but the logic is pretty straight forward.
dt = current data table();
dt << New Column( "STATUS", formula(
If( :TIME == "BASELINE",
theRow = Row();
thePatient_ID = :PATIENT_ID;
If(:LAB_VALUE == "NORMAL",
If( N Rows( dt << get rows where(
Row()>theRow &
thePatient_ID == :PATIENT_ID &
(:LAB_VALUE == "MILD" | :LAB_VALUE == "SEVERE")
)
) > 0
,
1,
)
,
:LAB_VALUE =="MILD",
If( N Rows( dt << get rows where(
Row()>theRow &
thePatient_ID == :PATIENT_ID &
:LAB_VALUE == "SEVERE"
)
) > 0
,
2
)
,
:LAB_VALUE == "SEVERE"
If( N Rows( ct << get rows where(
Row()>theRow &
thePatient_ID == :PATIENT_ID &
(:LAB_VALUE == "MILD" | :LAB_VALUE == "NORMAL")
)
) > 0
,
3
)
)
)
)
);
I can imagine a more efficient way to do this, but it would not be implemented as a formula, but as a script using some of the JMP Platforms.