cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Instantly extract effect sizes, F-ratios, and FDR-adjusted p-values from your models with the Calculate Effects Sizes extension, available now in the JMP Marketplace!
  • New to JMP? Join us Sept. 23-24 for the Early User Edition of Discovery Summit, tailor-made for new users. Register now for free!
  • Your voice matters! Tell us how you prefer to receive JMP updates, so we can tailor our communication to your needs. Take short survey.

Discussions

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

not equal to symbol

Hi,

I have the following script and it does not select the correct columns names ("Std"). Here is the script:

 

cols = dt << Get column Names();
 
for( i = 1, i <= N Items( cols ), i++,
if( contains( cols[i] , "Std")  != 1
,
Column( dt, cols[i] ) << Set Data Type( "Character" );
Column( dt, cols[i] ) << Set Modeling Type ("Nominal")
)
);

 

 

Looks like != does not do the job. Any help on this? Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
AT
AT
Level V

Re: not equal to symbol

Thanks so much for quick help. Replacing 1 by 0 works perfectly.

View solution in original post

2 REPLIES 2
cwillden
Super User (Alumni)

Re: not equal to symbol

The way I read your script, it will only change the data and modeling type for columns that immediately start with "Std" (e.g. a column named "Std Dev" would be modified, but a column named "Col Std" would not).

Contains() returns the position in the string of the substring you specified.  If cols[i] = "Std Dev", Contains(cols[i],"Std") will return the value 1.  If cols[i] = "Col Std", then Contains(cols[i], "Std") will return the value 5 because that "Std" starts with the 5th character in the string.  Only if I try a column name that doesn't have the "Std" in the name will Contains() return 0.

Contains(cols[i], "Std")  != 1 will return true for all columns names that don't immediately start with "Std".

Typically, the way to use Contains() to determine if a substring is contained within a string would be to use either "!=0" or ">0".  Switch the 1 to a 0 and see if that works.

-- Cameron Willden
AT
AT
Level V

Re: not equal to symbol

Thanks so much for quick help. Replacing 1 by 0 works perfectly.

Recommended Articles