cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Submit your abstract to the call for content for Discovery Summit Americas by April 23. Selected abstracts will be presented at Discovery Summit, Oct. 21- 24.
Discovery is online this week, April 16 and 18. Join us for these exciting interactive sessions.
Choose Language Hide Translation Bar
ron_horne
Super User (Alumni)

finding the mode

hi everyone,

i would like to produce a table summery that gives the mode of a variable for each category of another variable.

ideally, this would work:

dt = open ("$SAMPLE_DATA/Mail Messages.jmp");
dt << summary ( Group ( :From ), Mode (:To) );

alternatively, i would stack the table by "From" and calculate the mode at each row. yet, "Mode" is not an option in Table summary or column formula.

any ideas calculating the mode are welcome including in sending to SAS.

i am using JMP 10.

thank you,

Ron

11 REPLIES 11

Re: finding the mode

I believe that this will also produce the intended result:

dt = open ("$SAMPLE_DATA\Cars.jmp");

dt2 = dt << summary(group(:Make, :R Leg));

dt2 << selectwhere(colmaximum(:n rows, :make) != :n rows) << Delete Rows;

Cheers,

Brady

ron_horne
Super User (Alumni)

Re: finding the mode

Thank you Brady,

This is by far the most parsimonious and robust script.

I would like to add one optional line of code to disable the possibility of missing values as the mode:

dt = open ("$SAMPLE_DATA\Cars.jmp");

dt2 = dt << summary(group(:Make, :R Leg));

// option to disable the possibility of missing values as modes

dt2 << Select Where ( IsMissing (:R Leg)) << Delete Rows;

dt2 << selectwhere(colmaximum(:n rows, :make) != :n rows) << Delete Rows;