你好@金瑟约瑟夫,
建立在@txnelson s 方法可能有一个使用一些内置功能的速记脚本。这是通过脚本的最大点击和最小泛化来实现的。
这种方法使用两个命令:组合和文本到列。 combine 的优势在于它可以忽略缺失值。在这种情况下,它被用作没有缺失值的连接。
然后,当我们想要将最终数据放在单独的列中时,文本到列就派上用场了。
请让我们知道它是否有效或需要为您的目的进一步概括。
朗
dt = New Table( "original data set",
Add Rows( 36 ),
New Column( "Data 01",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [1, 1, 1, ., ., ., ., ., ., ., ., ., ., ., ., 11, 11, 11, ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., .] )
),
New Column( "Data 02",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [., ., ., 2, 2, 2, ., ., ., ., ., ., ., ., ., ., ., ., 12, 12, 12, ., ., ., ., ., ., ., ., ., ., ., ., ., ., .] )
),
New Column( "Data 03",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [., ., ., ., ., ., 3, 3, 3, ., ., ., ., ., ., ., ., ., ., ., ., 13, 13, 13, ., ., ., ., ., ., ., ., ., ., ., .] )
),
New Column( "Data 04",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [., ., ., ., ., ., ., ., ., 4, 4, 4, ., ., ., ., ., ., ., ., ., ., ., ., 14, 14, 14, ., ., ., ., ., ., ., ., .] )
),
New Column( "Data 05",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [., ., ., ., ., ., ., ., ., ., ., ., 5, 5, 5, ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., .] ),
Set Display Width( 59 )
),
New Column( "Data 06",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [10, 10, 10, ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., .] )
),
New Column( "Data 07",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [., ., ., 20, 20, 20, ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., 200, 200, 200, ., ., ., ., ., ., ., ., .] )
),
New Column( "Data 08",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [., ., ., ., ., ., 30, 30, 30, ., ., ., ., ., ., ., ., ., ., ., ., 300, 300, 300, ., ., ., ., ., ., ., ., ., ., ., .] )
),
New Column( "Data 09",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [., ., ., ., ., ., ., ., ., 40, 40, 40, ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., .] ),
Set Display Width( 67 )
),
New Column( "Data 10",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [., ., ., ., ., ., ., ., ., ., ., ., 50, 50, 50, ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., .] )
)
);
// now we get to work
// Get the columns names to combine.
colNames = dt << get column names( string, continuous );
// Combine columns using list - here is the trick, it ignores missing values
dt << Combine Columns(
columns( eval (colNames) ),
Column Name( "combined" ),
Delimiter( "," ),
Multiple Response( 0 )
);
// Text to columns - now we can uncombine the data into as many columns there is actual data. this is robust to any number of events per row.
dt << Text to Columns(
columns( :combined ),
Delimiters( "," )
);