help with codepara = {"Age","Orientation","Preference","Salary","Number","SN","Years","Service"} //some of the column names needed
main_table_col_remain = main_tab << get column names(string);
For( i = N Items( main_table_col_remain ), i > 0, i--,
If(!Contains( main_table_col_remain[i],<FONT color="#FF0000"> ??</FONT> ) ,
Remove From( main_table_col_remain, i )
));
What do i put in the "??" part? I've been circling around this code for a while now. I want to remove column names not stored in para.
Re: help with codeYou had the comparison backwards. You want to take the main_table_col_remain[1] and look into the para list to see if it is there then remove it from the main_table_co_remaining list
para = {"Age", "Orientation", "Preference", "Salary", "Number", "SN", "Years", "Service"}; //some of the column names needed
main_table_col_remain = main_tab << get column names( string );
For( i = N Items( main_table_col_remain ), i > 0, i--,
If( Contains( Para, main_table_col_remain[i] ),
Remove From( main_table_col_remain, i, 1 )
)
);Re: help with codefollow up question, how do i tweak this code so that it does not split it individually?
for(i=1, i<=n, i++,
if((contains item(Para[i], main_table_col_remain) == 1),
param = main_table_col_remain[i];
tempdt =eval(parse( " combined_tab << Split(
Split By(:Source_Table),
Split(:Name(\!"" ||param|| "\!")),
Remaining Columns(Drop All),
Sort by Column Property
)"
))));
Re: help with codeIf I am correctly reading what you want to do, all you need to do, is to place all of the main_table_col_remain columns into the Split definition at the same time. Here is a simple example of splitting both Height and Weight by the Sex column in the Big Class sample data table
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/big class.jmp" );<BR />dt << Split(
Split By( :sex ),
Split( :height, :weight ),
Remaining Columns( Drop All ),
Sort by Column Property
);
With the complex names you have in your data table, I would have a tendency to add :Name() to each element in your main_table_col_remain and in your case, turn the list into a string
myString = ":Name( \!"" || char(main_table_col_remain[1]) || "\!" )";
For( I = 2, I<= N Items( main_table_col_remain ), i++,
myString = myString || ", :Name( \!"" || char(main_table_col_remain[i]) || "\!" )" ;
);
then you can add the entire list to the split
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/big class.jmp" );
main_table_col_remain = dt << get column names( string, continuous );
myString = ":Name( \!"" || Char( main_table_col_remain[1] ) || "\!" )";
For( I = 2, I <= N Items( main_table_col_remain ), i++,
myString = myString || ", :Name( \!"" || Char( main_table_col_remain[i] ) || "\!" )"
);
Eval(
Parse(
"
dtSplit = dt << Split(
Split By( :sex ),
Split( " || myString ||
" ),
Remaining Columns( Drop All ),
Sort by Column Property
);"
)
);