good morning,
someone can help me to debug this part of code
the code should open a dialog window for the current data table.
for the numeric columns selected by dialog, the script should impute the empty cells with the mean of own column...
but dont understand why for some reason doesnt work
dt = Current Data Table();
cd = Column Dialog(
Myregcol_x = Collist( " Select columns >>",MinCol (1) ),
Hlist(""),
);
regcol_x= cd["Myregcol_x"];
nitems = N Items( regcol_x );
colname_num={};
For( p = 1, p <= nitems, p++,
colname_num = regcol_x[p] << Get Data Type;
if (colname_num == "Numeric",
For( i = 1, i <= N items(regcol_x ), i++,
valuess = Column( regcol_x ) << get values( 1 );
valuess[Loc( Is Missing( valuess ) )] = Mean( valuess );
Column( regcol_x ) << setvalues( valuess, cc[i] );
);
);
);
thanks in advance
Gianpaolo
Fantastic!!!! , thanks a Lot
You had a logic error in your use of 2 For Loops. I simplified the script to where it works on one column at a time, which eliminated the second For Loop
Names Default To Here( 1 );
dt = Current Data Table();
cd = Column Dialog( Myregcol_x = Collist( " Select columns >>", MinCol( 1 ) ), Hlist( "" ), );
regcol_x = cd["Myregcol_x"];
nitems = N Items( regcol_x );
colname_num = {};
For( p = 1, p <= nitems, p++,
colname_num = regcol_x[p] << Get Data Type;
If( colname_num == "Numeric",
valuess = Column( regcol_x[p] ) << get values;
valuess[Loc( Is Missing( valuess ) )] = Mean( valuess );
Column( regcol_x[p] ) << setvalues( valuess, cc[p] );
);
);