cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
joydeepb83
Level I

Add a new value to rows of an existing column

Hi, I am new to JSL . I am trying to write a code do achieve the following. 

I have 4 different JMP table. I am comparing each row of column 1 of Table 1 with column 1 of the remaining three table. 

If any entry/row of Coulmn 1 /table 1 matches with column 1 of Table 2 , It assigns Character say- Group1 to the row in table 1/ Column 4. 

 

Similarly if any row of column 1/tale1 matches with column1 of table 3 and table 4 then it assigns a character say- Group 2 in table 1/column 4. 

I am successfully creating column 4 and after comparison with table 2. 

 

However I am finiding it difficulty to update the same column 4 with Group2 when I am comparing the rows of table1 /column1 with table 3/column1. 

Could anybody please help? 

 

*More specifically, how can I update my existing column with new character string for given condition. as I cant use -new column for that.*

 

 

Thansk 

 

jodyeep

 

 

 

 

 

 

 

2 REPLIES 2
txnelson
Super User

Re: Add a new value to rows of an existing column

Here are a couple of examples that I hope will give you a leg up with the script you are working on

Names Default To Here( 1 );
dt1 = New Table( "Table 1", New Column( "Col A", character, values( {"A1", "A2", "A3"} ) ) );
dt2 = New Table( "Table 2", New Column( "Col B", character, values( {"B1", "B2", "B3"} ) ) );
dt3 = New Table( "Table 3", New Column( "Col C", character, values( {"C1", "C2", "C3"} ) ) );

If( dt1:Col A[1] == "A1",
	dt2:Col B[3] = "Group 1"
);

If( dt2[2, 1] == "B2",
	Data Table( "Table 1" ):Col A[2] = "Looking Good"
);

 Here is a modification of your script that I believe will simplify the code

names default to here(1);

dt3 = Open( "\\Table 2" );

dt6 = Open( "Table 1" );
dt6 << New Column( "Group",
	Character)

m = N Rows( dt6 );
n = N Rows( dt3 );

For( i = 1, i <= m, i++,;
	For( j = 1, j <= n, j++,        
		If( Column( dt6, "Core ID" )[i] == (Column( dt3, "PC_ID" )[j]),
			dt6:Group[i] = "Group 1"
		);       
	);   
);               
 
dt6 << save( "Table1" );
 
 

//Close( dt3, nosave );
//Close( dt6, nosave );
Jim
joydeepb83
Level I

Re: Add a new value to rows of an existing column

Hi Jim. 

 

Thanks a lot for your help. The modification worked and got lot simplified. 

 

Thanks 

 

Joydeep