cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
Theresa
Level IV

How to realize If table BB, column C=="Y", then table AA column D result will fill in "Y" too accordingly. Other all values no change

Would you use 2 table as a example to show how to realize:

If table BB, column C=="Y", then table AA column D result will fill in "Y" too accordingly. Other all values no change.

 

My JMP version is V14. Thanks for your help

6 REPLIES 6
txnelson
Super User

Re: How to realize If table BB, column C=="Y", then table AA column D result will fill in "Y" too accordingly. Other all values no change

Here is a simple script that performs the task that you specified, or at least how I interpreted what you stated.

Names Default To Here( 1 );
bb = Open( "$sample_data/big class.jmp" );
// Change the Sex column name to "C" to match your example
bb:sex << set name( "C" );

// Create a Blank data table with a column called "D"
aa = New Table( "Change", add rows( 40 ), New Column( "D", character ) );

// If a vlaue in row 2 for column C in table referenced by BB == "F",
// then set the same row value in data table AA column D to "F"
If( BB:C[2] == "F",
	AA:D[2] = "F"
);

// or using a different notation
If( BB[2,3] == "F",
	AA[2,1] = "F"
);
Jim
Theresa
Level IV

Re: How to realize If table BB, column C=="Y", then table AA column D result will fill in "Y" too accordingly. Other all values no change

Thanks for reply. It works.

But i want realize that if any values in column C=="F", then column D in Table AA =F,  So what should i do? To remove the specific row like [2] information?

I try below scripts, it is not work, thanks. Some times the data table is thousands of rows, i want to see a situation that is no specific rows called out, thanks.

 

Pls help on this , thanks.

 

If( BB:C == "F", AA:D = "F" );
jthi
Super User

Re: How to realize If table BB, column C=="Y", then table AA column D result will fill in "Y" too accordingly. Other all values no change

You could add For Each Row around the if statements. See Scripting Index and For Each Row for more details

For Each Row(
	If( BB:C == "F",
		AA:D = "F"
	);
);

 

-Jarmo
Theresa
Level IV

Re: How to realize If table BB, column C=="Y", then table AA column D result will fill in "Y" too accordingly. Other all values no change

Got it thanks

txnelson
Super User

Re: How to realize If table BB, column C=="Y", then table AA column D result will fill in "Y" too accordingly. Other all values no change

I believe the most efficient way to handle this is:

AA:D[ BB << Get Rows Where( BB:C == "F" ) ] = "F";
Jim
jthi
Super User

Re: How to realize If table BB, column C=="Y", then table AA column D result will fill in "Y" too accordingly. Other all values no change

There is also the option to use Loc but it might be a bit more difficult to understand than get rows where:

AA:D[Loc(BB:C << get as matrix, "F")] = "F";
-Jarmo