Subscribe Bookmark RSS Feed

Creating Subset of a subset

neelam

Community Trekker

Joined:

May 13, 2013

I wanted to create a subset from a subset both created using filters, I tried searching everywhere but didn't find what I was looking for (didn't understand many ).

I would be grateful if you could help.

I am using JMP 9.02

//this is my data table

Open("C:\DTR\DITR.jmp",

//I want to select rows with BRT and JML in stations column

Add Filter(columns(:Stations), Where(:Stations == "BRT","JML"),Mode( Select( 0 ), Include( 1 ) ) ));

//and then create a subset "Regions" from the selection

subset(output table name( "regions" ),Selected Rows( 1 ), selected columns( 0 ));

// (I cannot get it to work past this segment)

//I want to filter and create a subset form the subset "regions" created above

"regions"<< Add Filter(columns(:Months), Where(:Months == "January"), Mode( Select( 0 ), Include( 1 ) )) ;

//save the new subset as "months_regions"

subset(output table name( "months_regions" ),Selected Rows( 1 ), selected columns( 0 ));

//and apply a model to the new data table created after second subset

New Window("subset - Fit Least Squares", Fit Model(Y(:DTR), Effects(:Station Name,:Year, :Station Name * :Year), Personality(Standard Least Squares), Emphasis(Effect Leverage),   Run(:DTR << {Lack of Fit(0), Plot Actual by Predicted(1), Plot Residual by Predicted(1),   Plot Effect Leverage(1)})))

1 ACCEPTED SOLUTION

Accepted Solutions
Solution

Here's an example that may help you with the jsl syntax.

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

dt << data Filter( add filter( columns( :age ), Where( :age == {12, 13} ) ), Mode( Select( 1 ) ) );

sub1 = dt << subset( output table name( "regions" ), Selected Rows( 1 ), selected columns( 0 ) );

sub1 << data Filter( add filter( columns( :sex ), Where( :sex == "F" ) ), Mode( Select( 1 ) ) );

sub2 = sub1 << subset( output table name( "months_regions" ), Selected Rows( 1 ), selected columns( 0 ) );

//and apply a model to the new data table created after second subset

sub2 << Fit Model( Y( :weight ), Effects( :height ), Personality( Standard Least Squares ), Run );

However, with data filters it's possible to filter after several critera in one step, making the intermediate subset redundant.

dt << Data Filter(

  Add Filter( columns( :age, :sex ), Where( :age == {12, 13} ), Where( :sex == "F" ) )

);

2 REPLIES
Solution

Here's an example that may help you with the jsl syntax.

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

dt << data Filter( add filter( columns( :age ), Where( :age == {12, 13} ) ), Mode( Select( 1 ) ) );

sub1 = dt << subset( output table name( "regions" ), Selected Rows( 1 ), selected columns( 0 ) );

sub1 << data Filter( add filter( columns( :sex ), Where( :sex == "F" ) ), Mode( Select( 1 ) ) );

sub2 = sub1 << subset( output table name( "months_regions" ), Selected Rows( 1 ), selected columns( 0 ) );

//and apply a model to the new data table created after second subset

sub2 << Fit Model( Y( :weight ), Effects( :height ), Personality( Standard Least Squares ), Run );

However, with data filters it's possible to filter after several critera in one step, making the intermediate subset redundant.

dt << Data Filter(

  Add Filter( columns( :age, :sex ), Where( :age == {12, 13} ), Where( :sex == "F" ) )

);

neelam

Community Trekker

Joined:

May 13, 2013

Thank you MS, that solved it.