cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Discussions

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

Col Score in reverse order options?

Hey everyone,

Is there an easy way to reverse the order using the Col Score() function?  The default is that it scores it by descending order, so if something has the highest value it is given the highest score and the smallest value is given the score of 1.  I'd like the highest value to be a score of 1 and the lowest value to be the lowest score.

 

Thanks for any input!

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Col Score in reverse order options?

Here is how I would do it

Names Default To Here( 1 );
Open( "$SAMPLE_DATA/Big Class.jmp" );
New Column( "Score Height",
	formula( col score(:Height))
);
New Column( "Height reverse",
	Formula( col max(:height)-:height + col min(:height))
);
current data table()<<rerun formulas;
New Column( "score Height reverse",
	set each value( col score(:height reverse))
);

current data table() << delete columns(:height reverse);
Jim

View solution in original post

3 REPLIES 3
txnelson
Super User

Re: Col Score in reverse order options?

Here is how I would do it

Names Default To Here( 1 );
Open( "$SAMPLE_DATA/Big Class.jmp" );
New Column( "Score Height",
	formula( col score(:Height))
);
New Column( "Height reverse",
	Formula( col max(:height)-:height + col min(:height))
);
current data table()<<rerun formulas;
New Column( "score Height reverse",
	set each value( col score(:height reverse))
);

current data table() << delete columns(:height reverse);
Jim
jthi
Super User

Re: Col Score in reverse order options?

You can combine it with Col Number for example

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");

dt << New Column("Score Height", Formula(Col Score(:height)));
dt << New Column("Score Height Reverse", Formula(Col Number(:height) - Col Score(:height) + 1));

dt << New Column("Score Height by age", Formula(Col Score(:height, :age)));
dt << New Column("Score Height by age Reverse", Formula(Col Number(:height, :age) - Col Score(:height, :age) + 1));

Write();

jthi_0-1790138853222.png

 

-Jarmo
shampton82
Level VII

Re: Col Score in reverse order options?

Thanks for the help @jthi and @txnelson .  Using your guidance, I came up with this that is working well

For use with a single column

Col Score( :height ) * -1 + 1 + Col Maximum( Col Score( :height ) )

For use with by columns:

Col Score( :height, :sex ) * -1 + 1 + Col Maximum( Col Score( :height, :sex ), :sex )

Appreciate the quick responses!

 

Steve

Recommended Articles