cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
zetaVagabond1
Level III

Subset Table Keeps Showing Old Rows – How to Clear Memory Between Runs?

I’m working on a JMP JSL script where I filter tables based on a user-provided list of values. I create filtered tables using Subset.

The issue I’m running into is:

  1. On the first run, the filtered table shows the correct rows.

  2. On the second run, if I input a new list, the filtered table sometimes still shows rows from the previous run, or combines old and new rows.

  3. I’m using Names Default To Here(1) and Clear Symbols() at the end of the script, but that does not fully clear the table from JMP memory, so Subset seems to retain references to old rows.

Is there a recommended way in JMP to completely clear memory references for tables before creating new subsets?

hows to make Subset filtering repeatable across multiple runs without old data showing up?

6 REPLIES 6
jthi
Super User

Re: Subset Table Keeps Showing Old Rows – How to Clear Memory Between Runs?

Can you provide example of your script? If you are using subset correctly, it won't show "old rows".

 

 

-Jarmo
hogi
Level XIII

Re: Subset Table Keeps Showing Old Rows – How to Clear Memory Between Runs?

could you please share a simplified version of your  code - as short as possible.
... starting with loading a data table , e.g.

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

Getting fast helpful answers to your questions 
Getting correct answers to correct questions quickly 

hogi
Level XIII

Re: Subset Table Keeps Showing Old Rows – How to Clear Memory Between Runs?

Most of such timing issues can be fixed via wait(0).
Just add it after the subset command - and maybe another one before the subset command.

zetaVagabond1
Level III

Re: Subset Table Keeps Showing Old Rows – How to Clear Memory Between Runs?

Thanks. I missed pasting the code , here is the snippet for reference ; reading the input list values via a window and then following : 

// Directory path
pathDir = "J:\jmp-data\raw_data";
fileList = Files In Directory(pathDir);
Show(fileList);



selectedValues = {};
For(i = 1, i <= N Items(fileList), i++,
	For(j = 1, j <= N Items(targetSource), j++,
		If(Contains(fileList[i], targetSource[j]),
			Insert Into(selectedValues, targetSource[j]);
			Break();
		);
	);
);

countValues = N Items(selectedValues);
Show(selectedValues);

FilterByValueList = Function({sourceTbl, valueList, outName},
    tempTbl = sourceTbl << Duplicate Window();
    tempTbl << Clear Row States;

    For(i = 1, i <= N Items(valueList), i++,
        val = valueList[i];
        tempTbl << Row Selection(
            Select Where(:Batch Number == val, Current Selection("Extend"))
        );
    );

    resultTbl = tempTbl << Subset(
        Selected Rows(1),
        Output Table Name(outName),
        Invisible
    );

    Return(resultTbl);
);

// Example usage:

RunDataSubset = FilterByValueList(DataRuns, SelectedValues, "RunDataSubset");
MetaSubset    = FilterByValueList(MetaRuns, SelectedValues, "MetaSubset");

 

I also found the window that is being created to take user input, has global variables and that could be the reason for old data to show up: 

                    SelectedValuestext = Select_Values_test0 <<get text;
                    SelectedValuesText0 = {};
					i=1;

 

SelectedValuesText0 = {}; -  still has nothing so whenever I run the code again it should take new user input values if they are diff. 

jthi
Super User

Re: Subset Table Keeps Showing Old Rows – How to Clear Memory Between Runs?

Where does the << Duplicate Window() come from and what is it supposed to do? 

jthi_1-1763962791739.png

 

JSL does have quite a lot of powerful functions you could use instead of using For() everywhere. You can go over lists faster using Filter Each, Transform Each, For Each and you can most likely do the selection without loop using Contains().

-Jarmo
zetaVagabond1
Level III

Re: Subset Table Keeps Showing Old Rows – How to Clear Memory Between Runs?

FilterByValueList = Function({sourceTbl, valueList, outName},
    tempTbl = sourceTbl << Duplicate Window();
    tempTbl << Clear Row States;

    For(i = 1, i <= N Items(valueList), i++,
        val = valueList[i];
        tempTbl << Row Selection(
            Select Where(:Batch Number == val, Current Selection("Extend"))
        );
    );

    resultTbl = tempTbl << Subset(
        Selected Rows(1),
        Output Table Name(outName),
        Invisible
    );

    Return(resultTbl);
);

// Example usage:

RunDataSubset = FilterByValueList(DataRuns, SelectedValues, "RunDataSubset");
MetaSubset    = FilterByValueList(MetaRuns, SelectedValues, "MetaSubset");
//SelectedValues is a list 

Recommended Articles