Estoy tratando de combinar un par de mesas juntas y tengo algunos problemas. Básicamente, mis hojas de datos se parecen a las siguientes
| Años | Sexo |
| Paciente A | 13 | METRO |
| Paciente B | 15 | F |
| | Diagnóstico |
Paciente A | Diabetes |
| Paciente A | HTA |
| Paciente B | Asma |
| Paciente B | HTA |
| Paciente B | Septicemia |
Estoy tratando de hacer una tabla para combinar los diagnósticos con los códigos de los pacientes (para que se vea como la tabla a continuación), pero cada diagnóstico de paciente se representa individualmente en mi formato de Excel actual en lugar de combinar cada paciente con todos sus diagnósticos. ¿Hay una manera fácil de combinar estas dos tablas? ¡Gracias!
| | Años | Sexo | Diabetes | HTA | Asma | Septicemia |
| Paciente A | 13 | METRO | 1 | 1 | 0 | 0 |
| Paciente B | 15 | F | 0 | 1 | 1 | 1 |
Esto es bastante fácil de hacer con un poco de manipulación usando Tablas->Dividir primero en la mesa de Diagnóstico. Solo necesita agregar una tercera columna de 1 que dividirá.

Solo necesita agregar una tercera columna de 1 que dividirá.

Luego es cuestión de buscar y reemplazar los valores faltantes (.) con 0s y usar Tablas->Unirse por Paciente.

La respuesta de Jeff es una gran respuesta.Aquí está mi versión, que usa el JSL creado usando pasos similares a los que usó Jeff, para crear la nueva tabla

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