Sto cercando di combinare un paio di tabelle insieme e sto riscontrando dei problemi. Fondamentalmente le mie schede tecniche sono simili alle seguenti
| Età | Sesso |
| Paziente A | 13 | m |
| Paziente B | 15 | F |
| | Diagnosi |
Paziente A | Diabete |
| Paziente A | HTN |
| Paziente B | Asma |
| Paziente B | HTN |
| Paziente B | Sepsi |
Sto cercando di creare una tabella per combinare le diagnosi con i codici paziente (per assomigliare alla tabella seguente), ma ogni diagnosi del paziente è rappresentata individualmente nel mio attuale formato excel piuttosto che combinare ogni paziente con tutte le sue diagnosi. C'è un modo semplice per combinare queste due tabelle? Grazie!
| | Età | Sesso | Diabete | HTN | Asma | Sepsi |
| Paziente A | 13 | m | 1 | 1 | 0 | 0 |
| Paziente B | 15 | F | 0 | 1 | 1 | 1 |
Questo è abbastanza facile da fare con una piccola manipolazione usando Tabelle->Dividi prima nella tabella delle diagnosi. Devi solo aggiungere una terza colonna di 1 che dividerai.

Devi solo aggiungere una terza colonna di 1 che dividerai.

Quindi si tratta di cercare e sostituire i valori mancanti (.) con 0 e utilizzare Tabelle->Unisciti da Paziente.

La risposta di Jeff è un'ottima risposta.Ecco la mia versione, che utilizza il JSL creato utilizzando passaggi simili utilizzati da Jeff, per creare la nuova tabella

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 );