如何計算與 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”})
),
新列(“數據”,字符,“標稱”,),
);