Choose Language Hide Translation Bar
Highlighted
Song
Occasional Contributor

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?

0 Kudos
1 ACCEPTED SOLUTION

Accepted Solutions
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

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!
Song
Occasional Contributor

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"

 

 

 

0 Kudos
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