cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Sign-in to the JMP Community will be unavailable intermittently Dec. 6-7 due to a system update. Thank you for your understanding!
  • We’re retiring the File Exchange at the end of this year. The JMP Marketplace is now your destination for add-ins and extensions.
  • JMP 19 is here! Learn more about the new features.

Discussions

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

Fill in Missing Values

I have a transpose with an odd symptom

 

SpannerHead_0-1736805007588.png

When the transpose executes and the first cell in a column is "Batch 0" and all the subsequent cells are empty, I would like to fill those cells as "Batch 1".  Any clue how I could do that?


Slán



SpannerHead
2 ACCEPTED SOLUTIONS

Accepted Solutions
txnelson
Super User

Re: Fill in Missing Values

Here is a little script that will do what you want

txnelson_0-1736806906722.png

If( :"RSC TCANEAL/ furnace/ 5139"n[1] == "Batch 0",
	Try(
		:"RSC TCANEAL/ furnace/ 5139"n[Current Data Table() << get rows where(
			Is Missing( :"RSC TCANEAL/ furnace/ 5139"n )
		)] = "Batch 1"
	)
);

Here is a complete example

Names Default To Here( 1 );
New Table( "Example",
	Add Rows( 25 ),
	New Column( "RSC TCANEAL/ furnace/ 5139",
		Character,
		Set Values(
			{"Batch 0", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
			"", ""}
		)
	)
);

If( :"RSC TCANEAL/ furnace/ 5139"n[1] == "Batch 0",
	Try(
		:"RSC TCANEAL/ furnace/ 5139"n[Current Data Table() << get rows where(
			Is Missing( :"RSC TCANEAL/ furnace/ 5139"n )
		)] = "Batch 1"
	)
);
Jim

View solution in original post

SpannerHead
Level VI

Re: Fill in Missing Values

Jim, thanks.  I modified this to iterate through columns from 4 onward and only act on columns that were empty apart from the first row.

 

colList1 = Data Table( "Transpose of History" ) << get column names( string );

For( i = 1, i <= N Cols( Data Table( "Transpose of History" ) ), i++, If( Column(colList1[i])[1] == "Batch 0" & Col N Missing( As Column(colList1[i]) ) == NRow()-1, Try( Column(colList1[i])[Current Data Table() << get rows where( Is Missing( As Column(colList1[i]) ) )] = "Batch 1" ) ) );

Slán



SpannerHead

View solution in original post

2 REPLIES 2
txnelson
Super User

Re: Fill in Missing Values

Here is a little script that will do what you want

txnelson_0-1736806906722.png

If( :"RSC TCANEAL/ furnace/ 5139"n[1] == "Batch 0",
	Try(
		:"RSC TCANEAL/ furnace/ 5139"n[Current Data Table() << get rows where(
			Is Missing( :"RSC TCANEAL/ furnace/ 5139"n )
		)] = "Batch 1"
	)
);

Here is a complete example

Names Default To Here( 1 );
New Table( "Example",
	Add Rows( 25 ),
	New Column( "RSC TCANEAL/ furnace/ 5139",
		Character,
		Set Values(
			{"Batch 0", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
			"", ""}
		)
	)
);

If( :"RSC TCANEAL/ furnace/ 5139"n[1] == "Batch 0",
	Try(
		:"RSC TCANEAL/ furnace/ 5139"n[Current Data Table() << get rows where(
			Is Missing( :"RSC TCANEAL/ furnace/ 5139"n )
		)] = "Batch 1"
	)
);
Jim
SpannerHead
Level VI

Re: Fill in Missing Values

Jim, thanks.  I modified this to iterate through columns from 4 onward and only act on columns that were empty apart from the first row.

 

colList1 = Data Table( "Transpose of History" ) << get column names( string );

For( i = 1, i <= N Cols( Data Table( "Transpose of History" ) ), i++, If( Column(colList1[i])[1] == "Batch 0" & Col N Missing( As Column(colList1[i]) ) == NRow()-1, Try( Column(colList1[i])[Current Data Table() << get rows where( Is Missing( As Column(colList1[i]) ) )] = "Batch 1" ) ) );

Slán



SpannerHead

Recommended Articles