The answer is yes. You can build any subsequent query you need, based upon a previous query(s)
Here is a simple, and silly example
Names Default To Here( 1 );
// Run a Query to get one set of information...in this case what ages are
// found for the females
dt = New SQL Query(
Version( 130 ),
Connection( "JMP" ),
JMP Tables(
["Big Class" => "\C:\Program Files\SAS\JMPPRO\14\Samples\Data\Big Class.jmp"]
),
QueryName( "SQLQuery1" ),
Select(
Column(
"age",
"t1",
Analysis Type( "Ordinal" ),
Numeric Format( "Fixed Dec", "0", "NO", "" )
)
),
From( Table( "Big Class", Alias( "t1" ) ) ),
Where( Custom( "sex = \!"F\!"", UI( Custom( Base( "Continuous" ) ) ) ) )
) << Run;
// Find the distinct ages
Summarize( dt, ages = by( :age ) );
// Build the required Where Clause for the next query
queryCode = "age in(" || ages[1];
For( i = 2, i <= N Items( ages ), i++,
queryCode = queryCode || ", " || ages[i]
);
// Close out the Where Clause
queryCode = queryCode || ")";
New SQL Query(
Version( 130 ),
Connection( "JMP" ),
JMP Tables(
["Big Class Families" =>
"\C:\Program Files\SAS\JMPPRO\14\Samples\Data\Big Class Families.jmp"]
),
QueryName( "SQLQuery3" ),
Select(
Column( "picture", "t1", Analysis Type( "None" ) ),
Column( "name", "t1" ),
Column(
"age",
"t1",
Analysis Type( "Ordinal" ),
Numeric Format( "Fixed Dec", "0", "NO", "" )
),
Column( "sex", "t1" ),
Column( "height", "t1", Numeric Format( "Fixed Dec", "0", "NO", "" ) ),
Column( "weight", "t1", Numeric Format( "Fixed Dec", "0", "NO", "" ) ),
Column( "sibling ages", "t1", Analysis Type( "Multiple Response" ) ),
Column( "sports", "t1", Analysis Type( "Multiple Response" ) ),
Column( "countries visited", "t1", Analysis Type( "Multiple Response" ) ),
Column( "family cars", "t1", Analysis Type( "Multiple Response" ) ),
Column( "reported illnesses", "t1", Analysis Type( "Unstructured Text" ) ),
Column( "age vector", "t1", Analysis Type( "Vector" ) )
),
From( Table( "Big Class Families", Alias( "t1" ) ) ),
// add the queryCode to the Where() function
Where( Custom( queryCode, UI( Custom( Base( "Continuous" ) ) ) ) )
) << Run;
Jim