cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
qspringleaf
Level III

how to fill columns missing content with a required content by JSL

kindly help to suggest how to fill columns missing content with a required content by JSL, from left to right, auto fill in missing content with "Sold", refer to below tables. (actually the table and the columns is not limited, more than the table list). many thanks

Find on JSL but not work,   :Name("Sold or not?")[ dt<< get selected rows ] = "Sold";

 

Column NameSold or not?  Column NameSold or not?
AppleNot  AppleNot
Orange   OrangeSold
pineappleNot--->'pineappleNot
blueberry   blueberrySold
durainNot  durainNot
pear   pearSold
banana   bananaSold
1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: how to fill columns missing content with a required content by JSL

Names Default To Here( 1 );
dt = Current Data Table();

colNames = dt << get column names( string, character );

// Just loop across the colNames list and remove the column 
// names that you don't want
For( i = N Items( colNames ), i >= 1, i--,
	If( Contains( colNames[i], "Sold or not?" ) == 0,
		Remove From( colNames, i, 1 )
	)
);

For( i = 1, i <= N Items( colNames ), i++,
	Column( dt, colNames[i] )[dt << get rows where( As Column( dt, colNames[i] ) == "" )] =
	"Sold"
);
Jim

View solution in original post

3 REPLIES 3
txnelson
Super User

Re: how to fill columns missing content with a required content by JSL

Here is one way of handling your issue

Names Default To Here( 1 );
dt = Current Data Table();

colNames = dt << get column names( string, character );

For( i = 1, i <= N Items( colNames ), i++,
	Column( dt, colNames[i] )[dt << get rows where( As Column( dt, colNames[i] ) == "" )] =
	"Sold"
);
Jim
qspringleaf
Level III

Re: how to fill columns missing content with a required content by JSL

Many thanks for the solution, if the table have more than two columns with content missing, how to fill in content only for specific colomn while not touching other columns?(like this table, only want to fill the column "Sold or not?")  can help to suggest and many thanks.

txnelson
Super User

Re: how to fill columns missing content with a required content by JSL

Names Default To Here( 1 );
dt = Current Data Table();

colNames = dt << get column names( string, character );

// Just loop across the colNames list and remove the column 
// names that you don't want
For( i = N Items( colNames ), i >= 1, i--,
	If( Contains( colNames[i], "Sold or not?" ) == 0,
		Remove From( colNames, i, 1 )
	)
);

For( i = 1, i <= N Items( colNames ), i++,
	Column( dt, colNames[i] )[dt << get rows where( As Column( dt, colNames[i] ) == "" )] =
	"Sold"
);
Jim