BookmarkSubscribe
Choose Language Hide Translation Bar
AT
AT
Community Trekker

Choose two columns from two different tables

Hi,

I like to choose two columns from two different tables (data table dt1, and dt2) and I ran the below script and it lists the varaibles names for data table dt1 only. Is there an issue with my script? I appreciate your help.

 

 

xvar = .;
yvar = .;
win = New Window( "Choose Two More Variables for Matching",
<<Modal,
<<On Validate(
// require the user to select two variables before clicking OK
Show( xvar, yvar );
If( Is Missing( xvar ) | Is Missing( yvar ),
0, // if xvar or yvar are missing, do nothing when OK is clicked
1
);
),
Text Box( " Select two numeric columns. " ),
H List Box(
Text Box( " Choose First " ),
x = Col List Box(
dt1, // data table reference
all, // display all columns from the data table
xvar = (x << Get Selected)[1];
// get the name of the selected column before the window closes
Show( xvar );
),
Text Box( "Choose Second" ),
y = Col List Box(
dt2,
all,
yvar = (y << Get Selected)[1];
Show( yvar );
)
)
);

 

0 Kudos
2 REPLIES 2
gzmorgan0
Super User

Re: Choose two columns from two different tables

The Scripting Index and teh JSL Syntax reference shows the proper syntax to be

Col List Box(<Data Table ("name" )>, <"all"|"character"|"numeric">, ....). See a modification of your script, using the Data Table( ) syntax seems to work. However, you cannot use these in one analysis or platform call unless the columns are in the same table or a the two tables are virtually linked.

 

dt1 = Open("$sample_data/big class.jmp");
dt2 = open("$sample_data/big class families.jmp");

xvar = .;
yvar = .;

win = New Window( "Choose Two More Variables for Matching", 
	<<Modal, 
	<<On Validate(

// require the user to select two variables before clicking OK

		 Show( xvar, yvar );

		 If( Is Missing( xvar ) | Is Missing( yvar ), 

			0
		 , // if xvar or yvar are missing, do nothing when OK is clicked
			1
		);
	), 

	Text Box( " Select two numeric columns. " ), 

	H List Box(
		Text Box( " Choose First " ), 
		x = Col List Box(
			Data Table(dt1 << get name), // data table reference
			all, // display all columns from the data table
			xvar = (x << Get Selected)[1];
// get the name of the selected column before the window closes
			Show( xvar );
		), 

		Text Box( "Choose Second" ), 
		y = Col List Box(
			Data Table(dt2<<get name), 
			all, 
			yvar = (y << Get Selected)[1];
			Show( yvar );
		)
	)
);
AT
AT
Community Trekker

Re: Choose two columns from two different tables

Thanks. It works.

0 Kudos