Batching-Rekodierung vieler SpaltenHallo,
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
)
);SkriptingRe: Batching-Rekodierung vieler SpaltenInnerhalb der Funktion zum erneuten Codieren von Spalten kennt JMP die Variable col nicht mehr, daher müssen Sie diesen Teil des Skripts auswerten Vor Die Recode-Spalte wird ausgewertet.Dazu können Sie die Funktionen Eval, Eval Expr und Expr wie folgt verwenden:
Names default to here(1);
dtSD = 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"}
)
)
);
a = "Recoded";
col = dtSD << get column names( );
dtSD << Begin Data Update;
For( i = 1, i <= N Items( col ), i++,
If( Contains( col[i], a ),
//Need to evaluate the name of the column before
e = Eval Expr(
Expr( dtSD ) << Recode Column(
As Column( Expr( col[i] ) ),
{Map Value( _rcOrig, {"", "Not Reported"}, Unmatched( _rcNow ) )},
Target Column( As Column( Expr( col[i] ) ) )
);
);
show(e); write("\!n");
eval(e);
)
);
dtSD << End Data Update
Beachten Sie, dass ich den Ausdruck als e gespeichert habe, damit er vor der Auswertung in das Protokoll geschrieben werden kann.Sie hätten Eval (Eval Expr) in dieselbe Zeile setzen können.
Es gibt viele Möglichkeiten, diesen Code zu erstellen. Hier einige Beispiele:
Fügen Sie einen Ausdruck mit Eval Insert, Eval Expr, Parse und Substitute in einen anderen ein