Choose Language Hide Translation Bar
Highlighted
ENTHU
Level III

Help with error message - Argument is wrong type in access or evaluation of 'Contains'

I need to check if the columns contain either of the 2 strings and then replace column value with value in another column.

Here's the code -

For(i=1,i<= NRows(dt),i++,
if(contains(:step[i],"NA")| contains(:step[i],".") ,
:step[i] = description[i];
)

);

 

But I get an error saying - argument is wrong type in access or evaluation of 'Contains'

What am I doing wrong here?

1 REPLY 1
Highlighted
txnelson
Super User

Help with error message - Argument is wrong type in access or evaluation of 'Contains'

I beleive the issue is that your column called "description" is not properly being scoped.  It needs to have a ":" in front of its reference ":description".

Here is an example using a sample data table, that does what you want

Names Default To Here( 1 );
dt = Open("$SAMPLE_DATA/Big Class.jmp");
For( i = 1, i <= N Rows( dt ), i++,
	If( Contains( :Name[i], "TIM" ) | Contains( :Name[i], "ROBERT" ),
		:Name[i] = :Sex[i]
	)
);
Jim
Article Labels

    There are no labels assigned to this post.