Choose Language Hide Translation Bar
Highlighted
Community Trekker

## Years since

I have a large databse of patients hospitalized for a certain condition.  I have been trying to make a new column to indicate the "years prior to death".  See below:

YEARpatientMortality_in365daysDeath yearYears before death
1990221
19955
1991221
19954
1991221
19954
1993221
19952
1995221*19950
2000789
20022
2001789
20021
2002789*20020
2001965
20054
2005965*20050

A star in mortality_in365days column means they died within the last 365 days.  I know the years before death will not be an exact calculation since depending on how long ago they died (30 days versus 365 days) it may mean they died the year prior.  I had set up JMP to make the death year column, and then make a simple subtraction formula to calculate years before death, but then I run into problems.  I had done it manually using the update feature since I am not very good at scripting yet.  If you can help me either with manual instructions or scripting please let me know.  Also, if you have any reccommendations for scripting books for JMP I would appreciate it.

Highlighted
Staff

## Years since

Here's a formula to compute Death Year that you can paste it into the formula editor:

Local( {pat, rows},

pat = :patient;

rows = Current Data Table() << Get Rows Where( :Mortality_in365days == "*" & :patient == pat );

If( N Rows( rows ) > 0,

:YEAR[rows][1],

.

);

)

It returns the year for the first row where the mortality has "*" and the patient is the same ID as the current patient.