cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Learn how to build custom Python data connectors and further customize JMP’s Data Connector Framework with the Python Data Connector Demo, available now in the JMP Marketplace!
  • See how to create experiments to support product design and ID useful product features. Register for June 12 webinar, 2pm US Eastern Time.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
dwaterson
Level III

counting rows based on values in another column

I have a column that defines a grouping, like a column called 'gender' that contains the values 'male' and 'female'. I want to know how many rows in the dataset = 'male' and how many rows in the dataset = 'female'.

2 ACCEPTED SOLUTIONS

Accepted Solutions
vince_faller
Super User (Alumni)

Re: counting rows based on values in another column

dt = current data table();

dt << Select Where(:Gender == "male");

male = nrows(dt << Get Selected rows());

dt << Select Where(:Gender == "female");

female = nrows(dt << Get Selected rows());

Vince Faller - Predictum

View solution in original post

pmroz
Super User

Re: counting rows based on values in another column

You can use Tables > Summary.  Here's a JSL version:

dt = open("$sample_data/Big Class.jmp");

dt << Summary( Group( :sex ), N );

There's also the SUMMARIZE command in JSL.  You need a numeric column to get this to work though:

summarize(gsex = by(:sex), gcount = count(:height));

print(gcount);

[18, 22]

View solution in original post

5 REPLIES 5
vince_faller
Super User (Alumni)

Re: counting rows based on values in another column

dt = current data table();

dt << Select Where(:Gender == "male");

male = nrows(dt << Get Selected rows());

dt << Select Where(:Gender == "female");

female = nrows(dt << Get Selected rows());

Vince Faller - Predictum
pmroz
Super User

Re: counting rows based on values in another column

You can use Tables > Summary.  Here's a JSL version:

dt = open("$sample_data/Big Class.jmp");

dt << Summary( Group( :sex ), N );

There's also the SUMMARIZE command in JSL.  You need a numeric column to get this to work though:

summarize(gsex = by(:sex), gcount = count(:height));

print(gcount);

[18, 22]

dwaterson
Level III

Re: counting rows based on values in another column

Thank you for these responses. Is there any way to do this within a column formula?

ms
Super User (Alumni) ms
Super User (Alumni)

Re: counting rows based on values in another column

Col Number(Row(), :Gender)

Re: counting rows based on values in another column

Thanks! This helped me out.

Recommended Articles