cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
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;