BookmarkSubscribeRSS Feed
Choose Language Hide Translation Bar
Highlighted
jkwiggins
Community Trekker

Re: How to replace Missing Values w/ '0' using JSL

Another way...

clsMat = dt << Get As Matrix(

  {"colA", "colB", ...}

   );

clsMat[Loc( Is missing(clsMat) )]=0;

:colA << Set Values(clsRej[0,1]);

:colB << Set Values(clsRej[0,2]);

etc.

logical indexing is often faster than loops

Jason Wiggins
masakit
Community Member

Re: How to replace Missing Values w/ '0' using JSL

cool! ... in the last 2 lines, clsRej should be replaced to clsMat, right?

meanwhile, do we have any similar solutions for character column?

0 Kudos
msharp
Super User

Re: How to replace Missing Values w/ '0' using JSL

Since no one else answered, the solution is the same, just grab character columns instead and set the rows equal to the character you find fitting--"N/A" in the below case.

Just be careful, setting it =0 will change the column to numeric and will remove all the character data, however ="0" should be fine.

dt = Current Data Table();

nc = dt << get column names( Character );

For( i = 1, i <= N Items( nc ), i++,

  nc[i][dt << get rows where( Is Missing( nc[i][] ) )] = "N/A"

);