몇 개의 테이블을 결합하려고 하는데 몇 가지 문제가 있습니다. 기본적으로 내 데이터 시트는 다음과 같습니다
| | 진단 |
환자 A | 당뇨병 |
| 환자 A | HTN |
| 환자 B | 천식 |
| 환자 B | HTN |
| 환자 B | 부패 |
나는 진단을 환자 코드와 결합하는 표를 만들려고 노력하고 있지만(아래 표처럼 보이도록), 각 환자 진단은 각 환자를 모든 진단과 결합하는 대신 현재 Excel 형식으로 개별적으로 표시됩니다. 이 두 테이블을 결합하는 쉬운 방법이 있습니까? 감사 해요!
| | 나이 | 섹스 | 당뇨병 | HTN | 천식 | 부패 |
| 환자 A | 13 | 중 | 1 | 1 | 0 | 0 |
| 환자 B | 15 | 에프 | 0 | 1 | 1 | 1 |
이것은 약간의 조작으로 수행하기 매우 쉽습니다. 테이블->분할 먼저 진단 테이블에서 분할할 1의 세 번째 열을 추가하기만 하면 됩니다.

분할할 1의 세 번째 열을 추가하기만 하면 됩니다.

그런 다음 검색의 문제이며 누락된 값(.)을 0으로 바꾸고 다음을 사용합니다. 테이블->조인 환자에 의해.

Jeff의 답변은 훌륭한 답변입니다.다음은 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 );