Share your ideas for the JMP Scripting Unsession at Discovery Summit by September 17th. We hope to see you there!
Choose Language Hide Translation Bar
Highlighted
jshaw04
Level III

Col sum filling issue

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
txnelson
Super User

Re: Col sum filling issue

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

View solution in original post

3 REPLIES 3
Highlighted
pauldeen
Level IV

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
txnelson
Super User

Re: Col sum filling issue

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

View solution in original post

Highlighted
jshaw04
Level III

Re: Col sum filling issue

This is what I was looking for.  Thank you!

Article Labels

    There are no labels assigned to this post.