Share your ideas for the JMP Scripting Unsession at Discovery Summit by September 17th. We hope to see you there!
Choose Language Hide Translation Bar
Highlighted
Song
Level III

How can i Specific value copy?

Names Default To Here( 1 );
db_test  = Open( "$SAMPLE_DATA/big class.jmp" );


mycol =  Column("age");
xf = db_test << get rows where(contains(column(1)[],"O"));
xm = db_test << get rows where(contains(column("sex")[],"M"));
xa = db_test << get rows where( mycol[]== 13);
show (xf, xm, xa);


New Column( "Select", "Character", <<Set each Value(:sex["xf"]) ); 

 

I'd like to select specific cells and add new column only specific value.

Above the script doesn't work.

How can i make it work?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
txnelson
Super User

Re: How can i Specific value copy?

I believe this is a simpler way to do what you want

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

dt << New Column( "Select",
	character,
	formula(
		If( Contains( As Column( 1 ), "O" ),
			:name,
			"Pass"
		)
	)
);
Jim

View solution in original post

3 REPLIES 3
Highlighted

Re: How can i Specific value copy?

I would separate the creation of the new column and populating the new column into two steps in this case. Here is a simplified version of your example to illustrate my approach.

 

Names Default To Here( 1 );

dt = Open( "$SAMPLE_DATA/big class.jmp" );

xf = dt << Get Rows Where( Contains( Column( 1 )[], "O" ) );

New Column( "Select", "Character" );
dt:Select[xf] = "M";
Learn it once, use it forever!
Highlighted
Song
Level III

Re: How can i Specific value copy?

@markbailey 

Thanks a lot for your help!

I have one more question. How can i write the name? not M

Below script didn't work.

 

Names Default To Here( 1 );

dt = Open( "$SAMPLE_DATA/big class.jmp" );

xf = dt << Get Rows Where( Contains( Column( 1 )[], "O" ) );

New Column( "Select", "Character" );
dt:Select[xf] = dt:name[xf];

xy = dt << Get Rows Where(
 	Is missing( :Select)
 );

dt:Select[xy] = "Pass"

 

 

 

Highlighted
txnelson
Super User

Re: How can i Specific value copy?

I believe this is a simpler way to do what you want

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

dt << New Column( "Select",
	character,
	formula(
		If( Contains( As Column( 1 ), "O" ),
			:name,
			"Pass"
		)
	)
);
Jim

View solution in original post

Article Labels

    There are no labels assigned to this post.