cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
chivukula
Level I

Column Formula to display difference between two rows of another column

My data set is-

Vg Ig Igs
0 1 1
1 5 4
2 7 2
3 3 -4

I would like to create column Igs which is difference between current row and previous row in the column Ig. Is it possible script something like this in jmp.

Thank you

Chivukula
1 ACCEPTED SOLUTION

Accepted Solutions
mpb
mpb
Level VII

Re: Column Formula to display difference between two rows of another column

Or this using the DIF function:

New Column( "lgs",
Numeric,
Continuous,
Formula( Dif( :lg, 1 ) )
)

If you are working interactively you can just create a new column and use the formula builder to enter the formula Dif(:lg, 1)

Michael

View solution in original post

7 REPLIES 7
mattf
Level V

Re: Column Formula to display difference between two rows of another column

Hi:

Perhas this is one way:

Re: Column Formula to display difference between two rows of another column

You can use the LAG function:

New Column( "lgs",
Numeric,
Continuous,
Formula( AsColumn("lg") - Lag( AsColumn("lg"), 1 ) ),
)
mpb
mpb
Level VII

Re: Column Formula to display difference between two rows of another column

Or this using the DIF function:

New Column( "lgs",
Numeric,
Continuous,
Formula( Dif( :lg, 1 ) )
)

If you are working interactively you can just create a new column and use the formula builder to enter the formula Dif(:lg, 1)

Michael
Srishti
Level III

Re: Column Formula to display difference between two rows of another column

Both the solutions given here work well. I have data that is similar, but in a date format. I want to calculate the difference between rows where the differences are in units such as 'day' or 'year' or 'week' or 'months'. Is there a way to do this?

txnelson
Super User

Re: Column Formula to display difference between two rows of another column

Look into the Scripting Index for the function

     Date Difference()

Help==>Scripting Index

Jim
chivukula
Level I

Re: Column Formula to display difference between two rows of another column

Thank you so much for helping.

Regards,
Chivukula
chivukula
Level I

Saving results from log window using JSL

Hello:

I am using bivarate plot and adding a fit line. I would like to save slope and intercept values in a text file. I am using following code:

biv=rbiv<Ex1=biv[NumberColBox(13)][2];
show(Ex1);

Show(Ex1) show the value of slope in the log file along with the log of entire session. Is it possible to send JSL command to save the values of just slopes and intercepts in to a new data table or seperate text file from the log.

Thank you

Regards,
Chivukula