Thanks Jim for the very fast response and solution.
For those wishing to see your script in action I am including the data building script from the example I provided and your JSL to report the columns which could be combined.
names default to here(1);
// Construct the initial data table
New Table( "Missing data initial",
Add Rows( 20 ),
New Column( "LOT_ID",
Character,
"Nominal",
Set Values(
{"AA_234_xx.1", "AA_234_xx.2", "AA_234_xx.3", "AA_234_xx.4",
"AA_234_xx.5", "AA_234_xx.6", "AA_234_xx.7", "AA_234_xx.8",
"AA_234_xx.9", "AA_234_xx.10", "AA_234_xx.11", "AA_234_xx.12",
"AA_234_xx.13", "AA_234_xx.14", "AA_234_xx.15", "AA_234_xx.16",
"AA_234_xx.17", "AA_234_xx.18", "AA_234_xx.19", "AA_234_xx.20"}
),
Set Display Width( 81 )
),
New Column( "Step1.v1",
Character( 6 ),
"Nominal",
Set Values(
{"SRD_01", "SRD_02", "SRD_01", "SRD_04", "SRD_02", "", "", "", "", "",
"SRD_01", "SRD_02", "SRD_01", "SRD_04", "SRD_02", "", "", "", "", ""}
),
Set Display Width( 58 )
),
New Column( "Step1.v2",
Character( 16 ),
"Nominal",
Set Values(
{"", "", "", "", "", "SRD_01", "SRD_02", "SRD_01", "SRD_04", "SRD_02",
"", "", "", "", "", "SRD_02", "SRD_02", "SRD_02", "SRD_02", "SRD_02"}
),
Set Display Width( 58 )
),
New Column( "Step2.v2",
Character( 16 ),
"Nominal",
Set Values(
{"COATER_02", "COATER_01", "", "", "COATER_02", "COATER_01", "COATER_02",
"COATER_02", "COATER_02", "COATER_01", "COATER_02", "COATER_02",
"COATER_01", "COATER_01", "COATER_01", "", "", "", "COATER_01",
"COATER_01"}
),
Set Display Width( 71 )
),
New Column( "Step2.v3",
Character( 16 ),
"Nominal",
Set Values(
{"", "", "COATER_01", "COATER_01", "", "", "", "", "", "", "", "", "",
"", "", "COATER_02", "COATER_02", "COATER_02", "", ""}
),
Set Display Width( 71 )
),
New Column( "Step3.v5",
Character( 16 ),
"Nominal",
Set Values(
{"DRIE_03", "DRIE_04", "DRIE_03", "", "", "", "", "", "", "DRIE_04",
"DRIE_03", "DRIE_04", "DRIE_03", "DRIE_04", "", "", "", "", "", ""}
),
Set Display Width( 58 )
),
New Column( "Step3.v6",
Character( 16 ),
"Nominal",
Set Values(
{"", "", "", "DRIE_04", "DRIE_03", "DRIE_04", "DRIE_03", "DRIE_04",
"DRIE_03", "", "", "", "", "", "DRIE_03", "DRIE_04", "DRIE_03",
"DRIE_04", "DRIE_03", "DRIE_04"}
),
Set Display Width( 58 )
),
New Column( "Step4.v1",
Character( 16 ),
"Nominal",
Set Values(
{"PRIME_06", "", "PRIME_07", "", "PRIME_06", "", "PRIME_07", "",
"PRIME_06", "", "PRIME_07", "", "PRIME_06", "", "PRIME_07", "",
"PRIME_06", "", "PRIME_07", ""}
),
Set Display Width( 61 )
),
New Column( "Step4.v2",
Character( 16 ),
"Nominal",
Set Values(
{"", "PRIME_06", "", "PRIME_07", "", "PRIME_06", "", "PRIME_07", "",
"PRIME_06", "", "PRIME_07", "", "PRIME_06", "", "PRIME_07", "",
"PRIME_06", "", "PRIME_07"}
),
Set Display Width( 61 )
)
);
// Check the Missings Data Patern
Data Table( "Missing data initial" ) <<
Missing Data Pattern(
columns(
:Step1.v1,
:Step1.v2,
:Step2.v2,
:Step2.v3,
:Step3.v5,
:Step3.v6,
:Step4.v1,
:Step4.v2
),
Output Table( "Missing Data Pattern" )
);
// Check for columns which could be combined
// *** JSL written by txnelson ***
dt=Data Table( "Missing Data Pattern");
cols1List = {};
cols2List = {};
For( i = 4, i <= N Cols( dt ), i++,
comp = Associative Array( dt << get rows where( As Column( dt, i ) == 1 ) );
compMissing = Associative Array( dt << get rows where( As Column( dt, i ) == 0 ) );
If( N Items( comp ) > 0,
For( k = i + 1, k <= N Cols( dt ), k++,
comp2 = Associative Array( dt << get rows where( As Column( dt, k ) == 1 ) );
comp2Missing = Associative Array( dt << get rows where( As Column( dt, k ) == 0 ) );
comp2 << intersect( comp );
comp2Missing << intersect( compMissing );
If( N Items( comp2 << get keys ) == 0 & N Items( comp2Missing << get keys ) == 0,
Insert Into( cols1List, Column( dt, i ) << get name );
Insert Into( cols2List, Column( dt, k ) << get name );
);
)
);
);
nw = New Window( "Results",
Outline Box( "Columns that can be combined",
Table Box( String Col Box( "Column", cols1List ), String Col Box( "With", cols2List ) )
)
);
- Philip