如何计算与 JSL 的匹配?大家好!
excel中可以用“=offset(,match(,,)-1,match(,,)-1,,)”函数进行计算,但数据量大时速度较慢。
如何用 JSL 做到这一点?谢谢!
回复:如何计算与 JSL 的匹配?是的,excel在10000行以内使用工作表函数很方便。
超过 10,000 行我习惯于使用 VBA 字典执行此操作。但是超过 100,000 行的字典速度很慢。
现在用JMP的这个方法,过千万行也很快。谢谢!回复:如何计算与 JSL 的匹配?我看不出您上次回复中的声明对 JMP 用户社区有什么好处,
“在excel中用字典也很快……Set d = CreateObject("Scripting.Dictionary") “
似乎这样的评论放在Excel论坛上更合适
回复:如何计算与 JSL 的匹配?非常感谢您的帮助。
在excel中用字典也很快……Set d = CreateObject("Scripting.Dictionary")
但是必须以不同的方式完成超过一百万行。回复:如何计算与 JSL 的匹配?这里有几种方法,可以堆叠可变数量的列,如果您今天在 excel 中使用匹配,那么前两种方法之一可能会起作用:
//If the column positions do not change
d3_1 = d1 << Stack(
columns( Concat( [2 3], 4::10 )),
Source Label Column( "year" ),
Stacked Data Column( "data" ),
Drop all other columns( 1 ),
Keep( :state )
);
//If you want all columns
d1_clean = ( d1 << Subset( All rows, columns( 1::10 ) ) );
d3_2 = d1_clean << Stack(
columns( 2:: ncol(d1_clean) ),
Source Label Column( "year" ),
Stacked Data Column( "data" ),
Drop all other columns( 1 ),
Keep( :state )
);
//If the column names are in a specific format
// - get column names
cn = d1 << Get Column Names( string );
// - Find which columns match a format
// (jmp does have some patter matching tools but I like regex, check out regexr.com)
matches = repeat(0, N Items(cn));
for(c=1, c<= N Items(cn), c++, if(!is missing(Regex(cn[c], "^\d+$")), matches[c] = 1));
// - Stack
d3_3 = d1 << Stack(
columns( loc(matches) ),
Source Label Column( "year" ),
Stacked Data Column( "data" ),
Drop all other columns( 1 ),
Keep( :state )
);
回复:如何计算与 JSL 的匹配?如果这些列很多,比如超过1000……假设是一个日期。
这些列如何以变量循环的形式实现 d3 表设置。谢谢!

回复:如何计算与 JSL 的匹配?干得好!谢谢!回复:如何计算与 JSL 的匹配?由于您担心大表的速度,您可以创建一个长格式的“查找表”,这样每个值一行,然后使用 Join 或 Update 进行查找。这是它的样子:
Names default to here( 1 );
d1 = Open( "$SAMPLE_DATA/Presidential Elections.jmp" );
d2 = New Table( "offset",
Add Rows( 8 ),
New Column( "State",
Character,
"Nominal",
Set Values(
{"Wyoming", "Montana", "Montana", "Alaska", "Wisconsin", "Nebraska", "Nevada", "Montana"}
)
),
New Column( "year",
Character,
"Ordinal",
Set Values( {"1988", "1988", "1988", "1992", "2000", "1992", "2004", "1980"} )
),
New Column( "data",
Numeric,
"Continuous",
Format( "Fixed Dec", 12, 1 ))
);
//Move data to a long format
d3 = d1 << Stack(
columns(
:Name( "1980" ),
:Name( "1984" ),
:Name( "1988" ),
:Name( "1992" ),
:Name( "1996" ),
:Name( "2000" ),
:Name( "2004" ),
:Name( "2008" ),
:Name( "2012" )
),
Source Label Column( "year" ),
Stacked Data Column( "data" )
);
d3 << Set Name( "Long format" );
d3:year << Set Modeling Type("Ordinal");
//'Lookup' the values:
d2 << Update( with(d3), Match Columns( :state=:state, :year=:year ), Add Columns from Update table( None ));
d3 << Close window;
回复:如何计算与 JSL 的匹配?根据表“Presidential Elections”中的数据计算表“offset”中“data”的值。
谢谢你!回复:如何计算与 JSL 的匹配?d1 = Open( "$SAMPLE_DATA/Presidential Elections.jmp" );
d2 = 新表( "偏移量",
添加行(8),
新列(“状态”,
特点,
“标称”,
设置值(
{“怀俄明”,“蒙大拿”,“蒙大拿”,“阿拉斯加”,“威斯康星”,“内布拉斯加州”,“内华达”,“蒙大拿”}
)
),
新列(“年”,
特点,
“标称”,
设置值({“1988”,“1988”,“1988”,“1992”,“2000”,“1992”,“2004”,“1980”})
),
新列(“数据”,字符,“标称”,),
);