根据单元格值选择位置和子集你好,
我有下面的代码片段,我希望它从文件中获取列名称,然后创建一个新的子集表,然后查找所有数字列的平均值和 SD。 Mean 和 SD 代码可以工作,但它根本不创建子集表。有任何想法吗?我已经根据所有发布的讨论对此进行了检查。我已经尝试过“开头为”和“包含”条件
这是示例文件:
| 序列号 |
代码 |
区域 |
高度 |
重量 |
年龄 |
| 1 |
55414 |
北明尼阿波利斯 |
|
|
|
| 2 |
55455 |
明尼阿波利斯南 |
|
|
|
| 3 |
4446804e |
明尼阿波利斯东 |
|
|
|
| 4 |
4389568 |
明尼阿波利斯西 |
|
|
| 5 |
g58934 |
圣保罗N |
|
|
|
| 6 |
4989034 |
圣保罗E |
|
|
|
| 7 |
3496f |
圣保罗小号 |
|
|
|
| 8 |
5404390sfd |
明尼阿波利斯东 |
|
|
|
| 9 |
43960 |
北明尼阿波利斯 |
|
|
|
| 10 |
569043 |
圣保罗N |
|
|
|
| 11 |
6590549 |
圣保罗E |
|
|
|
dt3 = Open( "file_28.jmp" );
colcmp = "Area";
col = dt3 << get column names( string );
nc = N Items( col );
Show( nc );
For( j = 1, j <= nc, j++,
colname = Column( j ) << Get Name;
Show( colname );
If( Contains( colname, colcmp ),
dt3 << Select Where( Starts With( :colname, "Minneapolis" ) );
dt3 << Subset( Output Table Name( "MPLS" ), Selected Rows( 1 ), Selected columns only( 0 ) );
dt3 << Select Where( Starts With( :colname, "St. Paul" ) );
dt3 << Subset( Output Table Name( "STP" ), Selected Rows( 1 ), Selected columns only( 0 ) );
);
);
dtPM = Data Table( "MPLS" );
a = "Numeric";
colPM = dtPM << get column names( string );
ncPM = N Items( colPM );
Show( ncPM );
For( k = 1, k <= ncPM, k++,
colname = Column( k ) << Get Name;
Show( colname );
which = dtPM:colname << Get Data Type;
Show( which );
If( Contains( which, a ),
count = count + 1;
colnames2[count] = colname || "_MPLS";
Mean1[count] = Col Mean( :Column( k ) );
Std1[count] = Col Std Dev( :Column( k ) );
Show( Mean1[count] );
);
);
数据混合和清理回复:根据单元格值选择位置和子集谢谢吉姆。 我对如何将存储列名的变量传递给函数感到困惑,并且无法真正找到示例。 这清除了错误。
回复:根据单元格值选择位置和子集您是在告诉 JMP 查找名为 :colname 的列。在此引用中,JMP 不会评估 :colname 之外的列引用。您需要做的是在 As Column() 函数中指定名称。然后它会工作
For( j = 3, j <= nc, j++,
colname = Column( j ) << Get Name;
Show( colname );
If( Contains( colname, colcmp ),
dt3 << Select Where( Starts With( as column(colname), "Minneapolis" ) );
dt3 << Subset( Output Table Name( "MPLS" ), Selected Rows( 1 ), Selected columns only( 0 ) );
dt3 << Select Where( Starts With( as column(colname), "St. Paul" ) );
dt3 << Subset( Output Table Name( "STP" ), Selected Rows( 1 ), Selected columns only( 0 ) );
);
);