<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />I am still pretty new to JMP. I need help with the formula editor. I wanted to make a column (Y) that counts the number of variables that are the same in a different column (X). For example.
| X | Y |
|---|
| 22 | 3 |
| 22 | |
| 22 | |
| 345 | 1 |
| 567 | 3 |
| 567 | |
| 567 | |
| 99 | 1 |
| 777 | 2 |
| 777 | |
Is that possible? Any help would be appreciated.
Thanks,
Jeff
It is possible make such a formula. Here is two variants that should work. Just paste the script in the formula editor and hit enter. JMP will render the code into the typical formula editor style.
1. No empty rows in Y, Column X does not have to be sorted
Summarize( g = by( :X ), n = Count( :X ) );
Associative Array( g, As List( n ) )[Char( :X )]
2. Count only on first instance (as in your example above), Column X must be sorted.
Summarize( g = by( :X ), n = Count( :X ) );
aa = Associative Array( g, As List( n ) );
If(
Row() == 1, aa[Char( :X )],
:X[Row()] == :X[Row() - 1], .,
aa[Char( :X )]
)
If Column X is of type Categorical, you can go to Tables > Summary>select column X, Under statistics Choose N, Group By Column X.
You can then maintain this as a separate summary or have the option of joining it back to the main table using update command, matching with Column X. This would be a one time summary, not a dynamic formula.