cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
New to using JMP? Hit the ground running with the Early User Edition of Discovery Summit. Register now, free of charge.
Register for our Discovery Summit 2024 conference, Oct. 21-24, where you’ll learn, connect, and be inspired.
Choose Language Hide Translation Bar
StarfruitBob
Level VI

Transfer data between tables

Hello, I'm able to pull an SQL table that's in a very simple format. One column has a unique ID (UID) another column has column headers, and the third has a UID. I have another table where certain cells have the same UID. I want to plug the values from the first table ("UID") to the second, new table ("New").

 

Tabulate was the perfect tool to sort the column headers and give me a row count, but because the UID column contains both string and numeric data, I'm unable to directly populate the table with the values through tabulate, so instead I put the UID in for values in the tabulate tool. This at least gave me a way to correlate what value belongs where.

 

If tabulate can directly populate the actual values (no statistics needed) in place of needing to search for the UID between tables, this would be ideal.

 

Writing pseudocode is easy enough to show what needs to be done, but the JSL I'm not having luck with.  Can anyone help?

StarfruitBob_0-1670627409269.png

for( i = 1, i <= N Cols( data table( "New" ) ), i++, // col-by-col
		for( j = 1, j <= N rows( data table( "New" ) ), j++, // row-by-row
			if( isempty( column( data table( "New" ), i)[j] ), continue(), // if cell empty, move to next row
				id_val = column( data table( "New" ), i)[j] &
					id_loc = data table( "UID" ) << Get rows where( :UID == id_val) &
					data table( "New" ):eval( column( data table( "New" ))[j] = data table( "UID" ):UID[ id_loc[1] ]
			);
		);
);

Thank you for your time!

Learning every day!
1 ACCEPTED SOLUTION

Accepted Solutions
StarfruitBob
Level VI

Re: Transfer data between tables

Solved! Instead of trying to do this with JMP, I just asked someone to modify the SQL query to do this, which is much easier.

Learning every day!

View solution in original post

3 REPLIES 3
ron_horne
Super User (Alumni)

Re: Transfer data between tables

Hi @StarfruitBob 

perhaps the following can work for you.

 

 

Names Default To Here( 1 );

dtnew = New Table( "new",
	Add Rows( 3 ),
	New Column( "Column 1", Character, "Nominal", Set Values( {"1", "4", ""} ) ),
	New Column( "Column 2", Character, "Nominal", Set Values( {"", "3", ""} ) ),
	New Column( "Column 3", Character, "Nominal", Set Values( {"", "5", "2"} ) )
); 

dtuid = New Table( "uid",
	Add Rows( 5 ),
	New Column( "UID", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [1, 2, 3, 4, 5] ) ),
	New Column( "Val", Character, "Nominal", Set Values( {"apple", "12.3", "987", "abc", "3"} ) )
);

for (i=1, i<=ncols(dtnew), i++,
	for ( ii=1, ii <=nrows (dtnew), ii++,
	if ( Column (dtnew ,i)[ii] == "", continue (), 
	abc= num(  ( (Column (dtnew ,i)[ii])));
	Column (dtnew ,i)[ii] = char (dtuid:val[abc]);
	)));

the scripting feels very un natural.

let us know if it works for your application.

 

StarfruitBob
Level VI

Re: Transfer data between tables

Hello @ron_horne ,

 

Column (dtnew ,i)[ii] = char (dtuid:val[abc])

The line above doesn't link the UUID found in the cells of the dt:New to the row of dt:UID that has the corresponding value in :UID and then use that row number to save into the corresponding cell in dt:New.  Is there a simple command that can find a row number other than << Get rows where( :UID == abc )? If so, I think I can build off of what you answered above to complete this script.

 

Is there a way to make tabulate place in the actual values in the cells directly, regardless of data type & modeling, without statistics?

 

 

Learning every day!
StarfruitBob
Level VI

Re: Transfer data between tables

Solved! Instead of trying to do this with JMP, I just asked someone to modify the SQL query to do this, which is much easier.

Learning every day!