Hallo,
Ich habe versucht, viele Spalten, deren Spaltenname eine bestimmte Zeichenfolge enthält, mithilfe der Neukodierungsfunktion neu zu codieren. Ich denke, ich bin ziemlich nah dran, aber das Skript bleibt bei den Spaltenauswertungen hängen. Ich vermisse also irgendwo etwas Entscheidendes. Jede Anleitung wäre sehr dankbar.
Beste,
Sebastien
Names default to here(1);
Clear log();
New Table( "Subject_Demographics",
Add Rows( 48 ),
New Column( "Unique Subject Identifier",
Character,
"Nominal",
Set Selected,
Set Values(
{"8396882-P0101", "8396882-P0101", "8396882-P0102", "8396882-P0102",
"8396882-P0103", "8396882-P0103", "8396882-P0104", "8396882-P0104",
"8396882-P0201", "8396882-P0201", "8396882-P0202", "8396882-P0202",
"8396882-P0203", "8396882-P0203", "8396882-P0204", "8396882-P0204",
"8396882-P0301", "8396882-P0301", "8396882-P0302", "8396882-P0302",
"8396882-P0303", "8396882-P0303", "8396882-P0304", "8396882-P0304",
"8396882-P0401", "8396882-P0401", "8396882-P0402", "8396882-P0402",
"8396882-P0403", "8396882-P0403", "8396882-P0404", "8396882-P0404",
"8396882-P0501", "8396882-P0501", "8396882-P0502", "8396882-P0502",
"8396882-P0503", "8396882-P0503", "8396882-P0504", "8396882-P0504",
"8396882-P0601", "8396882-P0601", "8396882-P0602", "8396882-P0602",
"8396882-P0603", "8396882-P0603", "8396882-P0604", "8396882-P0604"}
)
),
New Column( "Alertness - Recoded",
Character,
"Nominal",
Set Selected,
Set Values(
{"", "", "", "", "", "", "", "", "", "", "Abnormal Finding",
"Abnormal Finding", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "Abnormal Finding", "Abnormal Finding", "Abnormal Finding",
"Abnormal Finding", "Abnormal Finding", "Abnormal Finding", "", "", "",
"", "Abnormal Finding", "Abnormal Finding", "", "", "", "", "", "", "",
"", "", ""}
)
),
New Column( "Xyx Reflex - Recoded",
Character,
"Nominal",
Set Selected,
Set Values(
{"Abnormal Finding", "Abnormal Finding", "Abnormal Finding",
"Abnormal Finding", "Normal", "Normal", "", "", "", "", "Normal",
"Normal", "Normal", "Normal", "Normal", "Normal", "Normal", "Normal",
"Normal", "Normal", "Normal", "Normal", "Normal", "Normal", "Normal",
"Normal", "Abnormal Finding", "Abnormal Finding", "Normal", "Normal",
"Normal", "Normal", "", "", "", "", "Abnormal Finding",
"Abnormal Finding", "Normal", "Normal", "Normal", "Normal", "Normal",
"Normal", "Normal", "Normal", "Normal", "Normal"}
)
),
New Column( "Ataxia - Recoded",
Character,
"Nominal",
Set Selected,
Set Values(
{"Abnormal Finding", "Abnormal Finding", "Abnormal Finding",
"Abnormal Finding", "Abnormal Finding", "Abnormal Finding",
"Abnormal Finding", "Abnormal Finding", "", "", "Abnormal Finding",
"Abnormal Finding", "", "", "", "", "", "", "", "", "", "", "", "",
"Abnormal Finding", "Abnormal Finding", "Abnormal Finding",
"Abnormal Finding", "", "", "Abnormal Finding", "Abnormal Finding", "",
"", "", "", "Abnormal Finding", "Abnormal Finding", "", "", "", "", "",
"", "", "", "Abnormal Finding", "Abnormal Finding"}
)
)
);
subject_incidence = Data Table( "Subject_Demographics" );
a = "Recoded";
col = subject_incidence << get column names( string );
show(col);
nc = N Items( col );
For( i = 1, i <= nc, i++,
If( Contains( col[i], a ),
subject_incidence << Begin Data Update;
subject_incidence << Recode Column(
column(subject_incidence, col[i]),
{Map Value( _rcOrig, {"", "Not Reported"}, Unmatched( _rcNow ) )},
Target Column( column(subject_incidence, col[i] ))
);
subject_incidence << End Data Update
)
);Ich glaube, der Code kann etwas einfacher sein als bei @ih
Ihr Code ermöglicht mit nur einer Änderung der Verwendung einer As Column()-Funktion statt nur einer Column()-Funktion eine korrekte Ausführung des Codes
subject_incidence = Data Table( "Subject_Demographics" );
a = "Recoded";
col = subject_incidence << get column names( string );
show(col);
nc = N Items( col );
For( i = 1, i <= nc, i++,
If( Contains( col[i], a ),
subject_incidence << Begin Data Update;
subject_incidence << Recode Column(
as column(subject_incidence, col[i]),
{Map Value( _rcOrig, {"", "Not Reported"}, Unmatched( _rcNow ) )},
Target Column( column(subject_incidence, col[i] ))
);
subject_incidence << End Data Update
)
);
Hier ist auch ein anderer Ansatz zur Lösung Ihres Problems, indem Sie „Get Rows Where()“ verwenden, um die Zeilen zu finden, die keinen Wert haben, und den Wert dieser Zeilen in „Nicht gemeldet“ ändern
subject_incidence = Data Table( "Subject_Demographics" );
a = "Recoded";
col = subject_incidence << get column names( string );
Show( col );
nc = N Items( col );
For( i = 1, i <= nc, i++,
If( Contains( col[i], a ),
Try(
Column( subject_incidence, col[i] )[subject_incidence <<
get rows where( as Column( subject_incidence, col[i] ) == "" )] = "Not Reported"
)
)
);