查找/將值複製到不同行的單元格中即使在論壇和JMP幫助文件中進行了大量搜索之後,我也無法找到解決我特定問題的良好解決方案。
我有一個患者的數據集,每個患者在連續的行中有多個階段的研究(因為每個患者的階段數不同)。 其中一列是相位,在每個患者的其中一行中,有一個稱為“基礎”的階段。我正在嘗試定義一個新變量,將Yy值“Base”放在與患者標識符相同的行中。 見下文:
病人# 患者姓名相 Yy =感興趣的變量新欄目=“基地”[由病人]
1患者XYZ abc 4 //在這裡要2
1 def 8
1 基礎 2
1 ghi 10
2患者MNO abc 45 //這裡需要54
2 def 36
2 ghi 24
2 基礎 54
3
3
3
3
任何幫助表示讚賞!
謝謝,
德魯
Re:查找/將值複製到不同行的單元格中有多種方法可以做到這一點。 @ron_horne 可以通過點擊來完成方法。下面的腳本使用一個關聯數組,在其他軟件中稱為字典或查找。
我錯過了 @ron_horne 的桌子,所以我有一個不同的。這是腳本,附件是一個表,該腳本作為表腳本加入。只需點擊即可運行。
Names default to here(1);
dt = current data table();
brows = dt << get rows where(:Phase == "Base");
aa = Associative Array( Column("Patient #")[brows], Column("Yy = Variable of interest")[brows]);
// patient numbers are the keys and the Base values, the values
nc = dt << New Column("New Column = \!"Base\!" [by patient]", numeric, Continuous);
nc << set each value(If(length(:Patient Name) > 0, aa[Column("Patient #")[]] ) );Re:查找/將值複製到不同行的單元格中你好 @ drmn43 ,
在附加的表上嘗試以下腳本。
否則,按照相同的步驟手動執行操作要容易得多。
dt = Current Data Table();
dt << select where( :Phase == "Base" );
subdt = dt << Subset( Selected Rows( 1 ) );
dt << clear select;
// make a sleek change of names
subdt << delete columns( "Base by Patient" );
subdt:Name( "Yy = Variable of interest" ) << Set Name( "Base by Patient" );
// Before updating the it is useful to delete columns that we do not want to updat
keep = {"Patient #", "Base by Patient"};
todelete = subdt << get column names( "string" );
For( icol = 1, icol <= N Items( keep ), icol++,
Remove From( todelete, Contains( todelete, Keep[icol] ), 1 )
);
subdt << delete columns( todelete );
dt << Update( With( Data Table( "Subset of Database" ) ), Match Columns( :Patient # = :Patient # ) );
Close( subdt, no save );
如果你需要其他行為空,我可以添加另一步或兩步來完成它。
羅恩