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
Theresa
Level III

Two percentage do comparison, if one column <another column, build a new column name with status fill in"Yes", otherwise "No"

 

This is the function i need and below script is workable when i test, but when i change the column name it do not work, pls check the pic: My column"Target Progress" and "Actual Progress" are the percentage this is a different with big class. How to revise the script?

 

workable scripts:

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

dt << New Column( "status", "Character", "Nominal" );

:status << Set Values( {"yes", "no"}[(:height << Get As Matrix) <= (:weight << Get As Matrix)] );

 

 

 

Failed scripts: "Target Progress" and "Actual Progress" are the percentage.

 

dt << New Column( "status", "Character", "Nominal" );

:status << Set Values(
	{"yes", "no"}[(:Actual Progress << Get As Matrix) >= (:Target Progress << Get As Matrix)]
);

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
vince_faller
Super User

Re: Two percentage do comparison, if one column <another column, build a new column name with status fill in"Yes", otherwise "No"

My guess is because the matrix you're giving is giving a zero.  

 

JMP indexing starts at 1 not 0. 

 

Try this. 

 

:status << Set Values({"yes", "no"}[((:Actual Progress << Get As Matrix) >= :Target Progress << Get As Matrix))+1]);

You should check that you're getting the right values for yes and no, you might want to swap the yes and no.  


But really I would just set them explicitly and use value labels. 

 

dt << new Column("Status", <<Set Each Value(:height <= :weight), 
	Value Labels({0 = "No", 1 = "Yes"}), 
	Use Value Labels(1)
)

 

 

 

 

 

 

 

 

Vince Faller - Predictum

View solution in original post

2 REPLIES 2
Highlighted
vince_faller
Super User

Re: Two percentage do comparison, if one column <another column, build a new column name with status fill in"Yes", otherwise "No"

My guess is because the matrix you're giving is giving a zero.  

 

JMP indexing starts at 1 not 0. 

 

Try this. 

 

:status << Set Values({"yes", "no"}[((:Actual Progress << Get As Matrix) >= :Target Progress << Get As Matrix))+1]);

You should check that you're getting the right values for yes and no, you might want to swap the yes and no.  


But really I would just set them explicitly and use value labels. 

 

dt << new Column("Status", <<Set Each Value(:height <= :weight), 
	Value Labels({0 = "No", 1 = "Yes"}), 
	Use Value Labels(1)
)

 

 

 

 

 

 

 

 

Vince Faller - Predictum

View solution in original post

Highlighted
Theresa
Level III

Re: Two percentage do comparison, if one column <another column, build a new column name with status fill in"Yes", otherwise "No"

Final use this works. Thank you so much.

dt = Current Data Table();
dt << New Column( "Actual Progress.",
	"Numeric",
	formula( If( :Target Complete >= :Actual Progress, "Yes", "No" ) )
);
Article Labels