cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Instantly extract effect sizes, F-ratios, and FDR-adjusted p-values from your models with the Calculate Effects Sizes extension, available now in the JMP Marketplace!
  • New to JMP? Join us Sept. 23-24 for the Early User Edition of Discovery Summit, tailor-made for new users. Register now for free!
  • Your voice matters! Tell us how you prefer to receive JMP updates, so we can tailor our communication to your needs. Take short survey.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
PS_Ato
Level III

Select multiple columns (numeric, continuous) and update missing column value ("" -> "0")

Hi,

I found the following example:

Select Multiple Columns and Update Missing Column Value [ May 28, 2019 10:21 PM (1195 views)]

and tried to modifiy it to my case, but without succes.

 

Column 4 to 14 (numeric, continuous) have missing values, and I would like to have "0" instead.

 

The script below only works for data type (character, nominal). What do I need to change to make it work for data type (numeric)?

 

 

Names Default To Here( 1 );

dt_corr = Current Data Table();

// Fill-up columns with "0", when empty.
colNames_corr = dt_corr << get column names( string );

For( i = 4, i <= N Items( colNames_corr ), i++, 
	dt_corr << select where( As Column( colNames_corr[i] ) == "" );

	If( N Rows( dt_corr << get selected rows ) > 0,
		As Column( colNames_corr[i] )[dt_corr << get selected rows] = "0"
	);
);

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Select multiple columns (numeric, continuous) and update missing column value ("" -> "0")

The script would need to be modified as such to work with numeric columns:

Names Default To Here( 1 );
dt_corr = Current Data Table();
// Fill-up columns with "0", when empty.
colNames_corr = dt_corr << get column names( string );
For( i = 4, i <= N Items( colNames_corr ), i++, 
	dt_corr << select where( is missing(As Column( colNames_corr[i] )) == 1  );
	If( N Rows( dt_corr << get selected rows ) > 0,
		As Column( colNames_corr[i] )[dt_corr << get selected rows] = 0
	);
);

View solution in original post

3 REPLIES 3
ron_horne
Super User (Alumni)

Re: Select multiple columns (numeric, continuous) and update missing column value ("" -> "0")

Re: Select multiple columns (numeric, continuous) and update missing column value ("" -> "0")

The script would need to be modified as such to work with numeric columns:

Names Default To Here( 1 );
dt_corr = Current Data Table();
// Fill-up columns with "0", when empty.
colNames_corr = dt_corr << get column names( string );
For( i = 4, i <= N Items( colNames_corr ), i++, 
	dt_corr << select where( is missing(As Column( colNames_corr[i] )) == 1  );
	If( N Rows( dt_corr << get selected rows ) > 0,
		As Column( colNames_corr[i] )[dt_corr << get selected rows] = 0
	);
);
PS_Ato
Level III

Re: Select multiple columns (numeric, continuous) and update missing column value ("" -> "0")

many thanks - wonderful

Recommended Articles