"apply" value labelsWhen I remove a formula from a column, the calculated values stay.
When I remove a Value Labels Property from a column, the values switch back to the original values.
Is there an alternative remove (~ "apply") function for value Labels, which converts the data type of the column to character and keeps the Value Labels?
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << New Column( "sex2",
Formula(Recode(:sex,{Map Value( _rcOrig, {"F", "female", "M", "male"} )}));
);
dt:sex 2 << Delete Formula;
dt:sex << Value Labels( {"F" = "female", "M" = "male"} ) << Use Value Labels( 1 );
dt:sex << delete property( Value Labels );Advanced Statistical ModelingData Blending and CleanupMass CustomizationQuality and Process EngineeringRe: "apply" value labelsI was not able to find any way to replace column values with the labels for the column. Perhaps another Community Member has a direct solution. But, as normal, JSL can supply a solution. Here is a script that will work with Character columns that have value labels.
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt:sex << Value Labels( {"F" = "female", "M" = "male"} ) << Use Value Labels( 1 );
replaceWithLabels = Function( {var},
Eval(
Parse(
"vl = Parse( Substr( Char( :" || var || " << get property( \!"value labels\!" ) ), 14,
Contains( Char( :" || var ||
" << get property( \!"value labels\!" ) ),\!")\!" ) - 14 ) );
:" || var || " << delete property( \!"value labels\!" );"
)
);
theFormula = "for each row(";
For( element = 1, element <= N Items( vl ), element++,
theFormula = theFormula || "if(:" || var || " ==" || Word( 1, Char( vl[element] ), "=" ) || ", :" || var || " =" ||
Word( 2, Char( vl[element] ), "=" ) || ");"
);
Eval( Parse( theFormula || ");" ) );
);
replaceWithLabels("sex");Re: "apply" value labelsAfter you have Value Labels set

and you go to recode columns you will have an option for recoding them


this seems to replace the values with labels
Re: "apply" value labelswonderful, thanks!