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

- JMP User Community
- :
- Discussions
- :
- Col sum filling issue

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

Highlighted

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

Nov 16, 2018 8:30 AM
(4065 views)

I am trying to fill in a column with the sum of another column given a certain condition.

For instance:

```
dt = open("$sample_data/big class.jmp");
dt = New column("value",numeric,formula(col sum(:height, :sex=="F")));
```

The new column "value" results in two values (1096 for Females and 1406 for Males). I would like the entire column to have the 1096.

I am using JMP Pro 14.1

1 ACCEPTED SOLUTION

Accepted Solutions

Highlighted

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

I think this will do what you want

```
dt = open("$sample_data/big class.jmp");
dt = New column("value",numeric,formula(col sum(If(:Sex == "F",:height, .))));
```

Jim

3 REPLIES 3

Highlighted
##

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

Re: Col sum filling issue

Your discreption is missing some of the conditions you are interested in, but here is one way to solve it:

```
dt = open("$sample_data/big class.jmp");
dtsum = dt << Summary(
Group( :sex ),
Sum( :height ),
Freq( "None" ),
Weight( "None" )
);
ValueYouWant = Column(dtsum,"Sum(height)")[1];
Close(dtsum, No save);
NewValues = J(n rows(dt),1,ValueYouWant);
dt = New column("value",numeric,Set Values( NewValues ));
```

Highlighted

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

I think this will do what you want

```
dt = open("$sample_data/big class.jmp");
dt = New column("value",numeric,formula(col sum(If(:Sex == "F",:height, .))));
```

Jim

Highlighted
##

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

Re: Col sum filling issue

This is what I was looking for. Thank you!

Article Labels

There are no labels assigned to this post.