I am working with a data table that has variable number of rows. I want to assign a categorical description that I will define to a new column called 'Reason 1'. This 'Reason 1' column will be assigned when the 'Name' column matches any of the strings in any of the lists that I have defined.
The 'Name' row entry will match exactly with an entry in the ::slitter, ::label, or ::case lists.
I want to assign the different reason 1 codes to all rows and then analyze the data according to each Reason 1.
dt1 << New Column("Reason 1", Character, "Nominal");
Nrows = N Rows(dt1);
For( i =1, i<=Nrows, i++
For( j=1, j<= N items( ::slitter ), j++,
If(:Name(i) == Eval(slitter(j)), :Reason 1(i) = "Slitter");
);
);
// %Slitter% description codes
slitter = {"TM2300-370",
"TM2300-380",
"TM2300-385",
"TM2300-390",
"TM2300-395",
"TM2300-400"};
// %Label% description codes (8)
::label = {"TM2300-020",
"TM2300-025",
"TM2300-070",
"TM2300-075",
"TM2300-080",
"TM2300-085",
"TM2300-090",
"TM2300-095"};
//%Case% description codes (7)
::case = {"TM2300-030",
"TM2300-035",
"TM2300-040",
"TM2300-045",
"TM2300-050",
"TM2300-055",
"TM2300-060"};