Here's an example, that should work.
It queries two tables from JMP sample tables, and joins them afterwards.
As others mentioned, there may be some issues for troubleshooting, probably you can find something in the log
- the referenced table needs to be saved
- the referenced table needs to have no duplicates
- are the references (table name, column name) correct?
- ...
The keys on both sides needs to be saturated with color, and not pale. Pale means not working.
I had some trouble with it, too, but it works.
// User Dialog for query from datatable (database)
/***************************************************************************/
// Initialization
/***************************************************************************/
Names Default To Here( 1 );
Clear Log();
// Query 1st table with filter conditions
dt_filter = New SQL Query(
Version( 130 ),
Connection( "JMP" ),
JMP Tables( ["Big Class" => "\C:\Program Files\SAS\JMPPRO\15\Samples\Data\Big Class.jmp"] ),
QueryName( "filter" ),
CustomSQL( "SELECT distinct t1.name, t1.age, t1.sex, t1.weight, t1.height FROM \!"Big Class\!" t1 where t1.sex = 'M' and t1.age<=13;" )
) << Run;
Summarize( name_lst = by( dt_filter:name ) );
dt_filter:name << set property("Link ID", 1);
dt_filter << save("$TEMP\dt_filter.jmp");
// (2) assign custom SQL,
Assign(
custom_sql,
"\[
SELECT t1.picture, t1.name, t1."sibling ages",
t1.sports, t1."countries visited", t1."family cars", t1."reported illnesses",
t1."age vector"
FROM "Big Class Families" t1
where t1.name in __NAMELIST__
;
]\"
);
// (3) Put namelist into custom_sql
Substitute Into( custom_sql, "__NAMELIST__", Substitute( Char( name_lst ), "{", "(", "}", ")" ) );
// (4) execute Query
dt_result = New SQL Query( Version( 130 ), Connection( "JMP" ),
, JMP Tables( ["Big Class Families" => "\C:\Program Files\SAS\JMPPRO\15\Samples\Data\Big Class Families.jmp"] ),
QueryName( "dt_result" ), CustomSQL( custom_sql ) )
<< Run;
dt_result << save("$TEMP\dt_result.jmp");
// (5) Connect both tables by symbolic link
dt_result:name << set property("Link Reference", Reference Table("$TEMP\dt_filter.jmp"));
Georg