建立與列列表對應的值列表我正在創建一個可能在使用的許多數據表之一中遇到的潛在列名稱列表,創建在打開的數據表中找到的實際列列表,然後嘗試創建與以下內容相對應的值列表實際的列列表。但是,當我運行以下程式碼時,它會從清單中第一列中取得我循環遍歷的所有列的值。此程式碼產生列表 = {13.975, 13.975} 而不是 {13.975, 105}。我為此嘗試了各種迭代,但無法獲得正確的值。任何建議將不勝感激。
Clear Log();
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\Big Class.jmp" );
dt_col_name_list = dt << Get Column Names( String );
dtsum = dt << Summary(
Mean( Eval( dt_col_name_list ) ),
Freq( "None" ),
Weight( "None" ),
statistics column name format( "column" )
);
// Potential column name list
pot_col_list = {"age", "mass", "height", "length" };
dtsum_col_name_list = dtsum << Get Column Names( String );
show(dtsum_col_name_list);
// Create empty list to hold names of the those measurement variables found in data table
act_col_list = {};
col_list_cnt = {};
// Run through data table column names and put those that match measurement variable list into new list
For( i = 1, i <= N Items( pot_col_list ), i++,
If( Contains( dtsum_col_name_list, pot_col_list[i] ),
Insert Into( act_col_list, pot_col_list[i] );
Insert Into( col_list_cnt, dtsum:pot_col_list[1,i] );
)
);
Show( col_list_cnt );回覆:建立與列列表相對應的值列表txnelson做到了,
感謝您查看並幫助糾正我的語法錯誤。
回覆:建立與列列表相對應的值列表用於從 pot_col_list 取得值的參考無效,請參閱下文以了解似乎有效的更正
names default to here(1);
Clear Log();
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\Big Class.jmp" );
dt_col_name_list = dt << Get Column Names( String );
dtsum = dt << Summary(
Mean( Eval( dt_col_name_list ) ),
Freq( "None" ),
Weight( "None" ),
statistics column name format( "column" )
);
// Potential column name list
pot_col_list = {"age", "mass", "height", "length" };
dtsum_col_name_list = dtsum << Get Column Names( String );
show(dtsum_col_name_list);
// Create empty list to hold names of the those measurement variables found in data table
act_col_list = {};
col_list_cnt = {};
// Run through data table column names and put those that match measurement variable list into new list
For( i = 1, i <= N Items( pot_col_list ), i++,
If( Contains( dtsum_col_name_list, pot_col_list[i] ),
Insert Into( act_col_list, pot_col_list[i] );
Insert Into( col_list_cnt, column(dtsum,pot_col_list[i])[1] );
)
);
Show( col_list_cnt );