- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
How do I change all occurrences of xyz:# to xyz
I need a script to loop across all character columns and find those who have the pattern xyz:#, and convert to xyz. I have a program that adds a numerical value to each duplicate sample I analyze, however, I recode each duplicate sample name to remove the assigned number as part of my data clean-up. Can this process be scripted? Thank you.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How do I change all occurrences of xyz:# to xyz
I think this will do what you want
Names Default To Here( 1 );
dt = Current Data Table();
colList = dt << get column names( character, string );
For( i = 1, i <= N Items( colList ), i++,
For Each Row(
as Column( dt, colList[i] ) = Try(
Word( 1, As Column( dt, colList[i] ), ":" )
,
As Column( dt, colList[i] )
)
)
);
If you are going to be continuing with scripting, you need to take the time to read the Scripting Guide in the JMP Documentation Library, available under the Help pull down menu.
The Discussion Group is not here to write code for the users, it is here to help users with issue they are finding when using JMP or in writing scripts. The community will always be here to assist JMP users with getting through the problems they run into.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How do I change all occurrences of xyz:# to xyz
abcd:#
zzqr:#
or are you referring to # as being a numeric place holder like
abcd:123
zzqr:874
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How do I change all occurrences of xyz:# to xyz
XYZ is a placeholder that is referring to what I named the sample. So for example, I analyze a sample that I name "Texas Tea" in triplicate, the program will return the data with the names, "Texas Tea:1, Texas Tea:2, and Texas Tea:3".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How do I change all occurrences of xyz:# to xyz
I think this will do what you want
Names Default To Here( 1 );
dt = Current Data Table();
colList = dt << get column names( character, string );
For( i = 1, i <= N Items( colList ), i++,
For Each Row(
as Column( dt, colList[i] ) = Try(
Word( 1, As Column( dt, colList[i] ), ":" )
,
As Column( dt, colList[i] )
)
)
);
If you are going to be continuing with scripting, you need to take the time to read the Scripting Guide in the JMP Documentation Library, available under the Help pull down menu.
The Discussion Group is not here to write code for the users, it is here to help users with issue they are finding when using JMP or in writing scripts. The community will always be here to assist JMP users with getting through the problems they run into.