- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: not equal to symbol
Thanks so much for quick help. Replacing 1 by 0 works perfectly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: not equal to symbol
Thanks so much for quick help. Replacing 1 by 0 works perfectly.