Replace 0 values with dot "Value Missing"How can I alter a data table to turn values which are set as 0 to dot, I found the script for changing dot to zero but not the alternative.
Thanks,
Data TableScriptingRe: Replace 0 values with dot "Value Missing"I would suggest taking a look at this post Should you Loop through a data table or use Recode, or use Get Rows Where to change values in a data table (and the original post) and the discussion there. If I remember correctly the point there was to replace 999 with missing value. The basic idea is usually to loop over rows or columns and replace values.
Re: Replace 0 values with dot "Value Missing"Here is one way of converting all of the "0" to a missing value, for a column named "A";
Names Default To Here( 1 );
dt = Current Data Table();
theRows = dt << get rows where( :A == 0 );
Try( :A[theRows] = . );
Re: Replace 0 values with dot "Value Missing"If you're trying to do the whole table you could jsut do
Names default to here( 1 );
dt = open("$SAMPLE_DATA\Big Class.jmp");
dt:weight[[1, 5, 6, 8]] = 0; // just setting them to 0
dt:height[[11, 15, 16, 18]] = 0;
wait(2);
// this is the bit you'll want
numeric_cols = dt << Get Column Names("Numeric", "string");
m = dt[0, numeric_cols]; // get the values as a matrix;
m[Loc(m==0)]=.; // set them to missing
dt[0, numeric_cols] = m; // set the data to the matrix