いくつかのテーブルを組み合わせようとしていますが、いくつか問題があります。 基本的に私のデータシートは次のようになります
| | 診断 |
患者A | 糖尿病 |
| 患者A | HTN |
| 患者B | 喘息 |
| 患者B | HTN |
| 患者B | 敗血症 |
診断と患者コードを組み合わせるためのテーブルを作成しようとしていますが(下の表のように)、各患者の診断をすべての診断と組み合わせるのではなく、現在のExcel形式で個別に表しています。 これら2つのテーブルを組み合わせる簡単な方法はありますか? ありがとう!
| | 年 | セックス | 糖尿病 | HTN | 喘息 | 敗血症 |
| 患者A | 13 | M | 1 | 1 | 0 | 0 |
| 患者B | 15 | F | 0 | 1 | 1 | 1 |
これは、を使用して少し操作するだけで非常に簡単に実行できますテーブル->分割最初に診断テーブルで。 分割する1の3番目の列を追加する必要があります。

分割する1の3番目の列を追加する必要があります。

次に、検索の問題であり、欠落している値(。)を0に置き換えて、テーブル->参加患者による。

ジェフの答えは素晴らしい答えです。これが私のバージョンです。これは、Jeffが使用したのと同様の手順を使用して作成されたJSLを使用して、新しいテーブルを作成します。

names default to here(1);
dtData = New Table( "The Data",
Add Rows( 5 ),
New Column( "Patient ID",
Character,
"Nominal",
Set Values(
{"Patient A", "Patient A", "Patient B", "Patient B", "Patient B"}
)
),
New Column( "Diagnosis",
Character( 16 ),
"Nominal",
Set Values( {"Diabetes", "HTN", "Asthma", "HTN", "Sepsis"} )
)
);
dtDemo = New Table( "The Demographics",
Add Rows( 2 ),
New Column( "Patient ID",
Character,
"Nominal",
Set Values( {"Patient A", "Patient B"} )
),
New Column( "Age", Character( 16 ), "Nominal", Set Values( {"13", "15"} ) ),
New Column( "Sex", Character( 16 ), "Nominal", Set Values( {"M", "F"} ) )
);
// Create a list with just the Patient IDs
summarize( dtData, theIDs = by( :Patient ID));
// Move it into a data table
dtIDs = New Table("theIDs", invisible, new column("Patient ID", character, values(theIDs)));
// Create a list with just the Diagnoses
summarize( dtData, theDiags = by( :Diagnosis));
// Move it into a data table
dtDiags = New Table("theDiags", invisible, new column("Diagnosis", character, values(theDiags)));
// Create a table with all possible combinations of patients and diagnoses
dtCart = dtIDs << Join( With( dtDiags ), Cartesian Join );
// Cleanup
close( dtIDs, nosave );
close( dtDiags, nosave);
// Add a null diagnosis column
dtCart << New Column("foundDiag", set each value(0));
dtData << New Column("foundDiag", set each value(1));
// Put the tables together
dtCart << Update(
With( dtData),
Match Columns( :Patient ID = :Patient ID, :Diagnosis = :Diagnosis )
);
// Split the data into the final form
dtSplit = dtCart << Split(
Split By( :Diagnosis ),
Split( :foundDiag ),
Group( :Patient ID ),
Sort by Column Property
);
// Make a copy of the demographics data table
dtFinal = dtDemo << subset( selected columns(0), selected rows(0));
// put the demographics file together with the split data table
dtFinal << Update(
With( dtSplit ),
Match Columns( :Patient ID = :Patient ID )
);
// Cleanup
close( dtSplit, nosave );
close( dtCart, nosave );