¡Si alguien puede ayudar con esto, lo agradecería enormemente!
Estoy tratando de crear una variable categórica que refleje los cambios en el empleo en función de dos variables: JOBCODE TimePoint 2 y JOBCODE TimePoint 2.
En esencia, esta variable categórica me permitirá ver si algún empleado tiene uno de los siguientes eventos desde el punto de tiempo 1 al punto de tiempo 2: se unió a la organización (nuevo empleado), cambió JOBCODE (transferido dentro de la organización) o dejó la organización ( terminación / separación).
El siguiente código representa mi estructura de datos porque los nuevos empleados tendrán un valor en blanco / nulo para su JOBCODE en Timepoint 1, los empleados despedidos tendrán un valor en blanco / nulo para JOBCODE en el Timepoint 2 y cualquier empleado que haya cambiado de puesto tendrá un CODIGO DE TRABAJO no coincidente en el campo desde el Punto de tiempo 1 al Punto de tiempo 2.
En cuanto al comando para blank / null, he intentado varias cosas diferentes. Intenté usar isMissing así como == "" y también he intentado! Contiene. Ninguno de ellos funciona. No tengo preferencia sobre cuál de estos estilos se usa mientras funcione.
Para aquellos empleados que se transfieren, solo estoy interesado en si mantuvieron o no un código de trabajo contenido en mi lista
Creé una tabla de datos simulados. La columna 1 contiene algunos ID de empleados inventados por el bien de ejemplo. Las columnas 2 y 3 representan códigos de trabajo en Timepoint 1 y Timepoint 2. La columna 4 es la salida que esperaría en función de los valores que ingresé en las columnas 2 y 3. La columna 5 contiene algunas notas para aclarar.
new column ("JOBCODE Status", Character, Nominal) << Formula
(If (Contains (mylist, :"JOBCODE Timepoint1") & !Contains (mylist, :"JOBCODE Timepoint2"),"Change in JOBCODE",
(If (Contains (mylist, :"JOBCODE Timepoint1") & Contains (mylist, :"JOBCODE Timepoint2"),"No Change",
(If (Contains (mylist, :"JOBCODE Timepoint1") & isMissing (:"JOBCODE Timepoint2"),
"Termination/Separation",
(If (isMissing (mylist, :"JOBCODE Timepoint1") & Contains (:"JOBCODE Timepoint2"),
"New Employee",
))))))));
mylist= {"HH0029",
"HH0030",
"HH0241",
"HH0242",
"HH0317",
"HH0635",
"HH0635",
"HH0636",
"HH0636",
"HH0639",
"HH0742",
"HH0750",
"HX0002",
"HX0003",
"HX0008",
"HX0010",
"HX0022",
"HX0106",
"HX0106",
"HX0107",
"HX0114",
"HX0115",
"SH0049",
"SH0504",
"SH0678",
"HH0113",
"HH0708",
"HH0746",
"HX0111",
"NU0017",
"NU0100",
"NU0200",
"NU0203",
"NU0206",
"NU0207",
"NU0213",
"NU0243",
"NU0244",
"NU0300",
"NU0301",
"NU0305",
"NU0327",
"NU0328",
"NU0362",
"NU0364",
"NU0400",
"NU0422",
"NU0423",
"NU0424",
"NU0425",
"NU0440",
"NU0461",
"NU0615",
"NU0618",
"NU0619",
"NU0620",
"NU0621",
"NU0622",
"NU0625",
"NU0800",
"NU0801",
"NU0923",
"NX0002",
"NX0006",
"NX0017",
"NX0018",
"NX0019",
"NX0023",
"NX0125",
"NX0465",
"NX0466",
"NX0609",
"NX0610",
"NU0610",
"NU0700",
"NU0710",
"NU0713",
"NU0922",
"NU0364",
"NX0609",
"NX0610"};Aquí está mi retrabajo de su código que parece funcionar
New Column( "myJOBCODE Status", Character, Nominal ) << Formula(
If( Row() == 1,
mylist = {"HH0029", "HH0030", "HH0241", "HH0242", "HH0317", "HH0635", "HH0635", "HH0636", "HH0636", "HH0639", "HH0742",
"HH0750", "HX0002", "HX0003", "HX0008", "HX0010", "HX0022", "HX0106", "HX0106", "HX0107", "HX0114", "HX0115", "SH0049",
"SH0504", "SH0678", "HH0113", "HH0708", "HH0746", "HX0111", "NU0017", "NU0100", "NU0200", "NU0203", "NU0206", "NU0207",
"NU0213", "NU0243", "NU0244", "NU0300", "NU0301", "NU0305", "NU0327", "NU0328", "NU0362", "NU0364", "NU0400", "NU0422",
"NU0423", "NU0424", "NU0425", "NU0440", "NU0461", "NU0615", "NU0618", "NU0619", "NU0620", "NU0621", "NU0622", "NU0625",
"NU0800", "NU0801", "NU0923", "NX0002", "NX0006", "NX0017", "NX0018", "NX0019", "NX0023", "NX0125", "NX0465", "NX0466",
"NX0609", "NX0610", "NU0610", "NU0700", "NU0710", "NU0713", "NU0922", "NU0364", "NX0609", "NX0610"}
);
isThere = Function( {value},
{},
If( Contains( mylist, value ),
1,
0
)
);
a = :JOBCODE Timepoint1;
b = :JOBCODE Timepoint2;
If(
isThere( a ) & b == "", "Termination/Separation",
a == "" & isThere( b ), "New Employee",
isThere( a ) & isThere( b ), "No Change"
);
);