Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- JMP User Community
- :
- Discussions
- :
- Discussions
- :
- Re: counting rows based on values in another column

Topic Options

- Start Article
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Apr 2, 2015 10:09 AM
(7469 views)

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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());

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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]**

5 REPLIES 5

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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());

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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]**

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: counting rows based on values in another column

Col Number(Row(), :Gender)

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: counting rows based on values in another column

Thanks! This helped me out.