Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- JMP User Community
- :
- Discussions
- :
- Set Row Values as Character Sequence

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Jun 4, 2013 11:51 AM
(7201 views)

Hi,

What is the best way to set row values for a given column as a character sequence?

This is easily done when creating a new column (Data Type == Character) by: Column Info --> Initialize Data --> Sequence Data --> "a", "b", "c", etc.

What is the best way to script this?

I am using JMP10.

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Clever workaround!

Here's another way I've used that may be more general and not requiring a formula (but there "should" be a simpler way..):

dt = Open**(** "$SAMPLE_DATA/Big Class.JMP" **)**;

labels = **{**"a", "b", "c"**}**; // could be any sequence

dt << New Column**(** "Char Sequence2",

Character,

Nominal,

Values**(**

Insert**(**

Repeat**(** labels, N Rows**(** dt **)** / N Items**(** labels **)** **)**,

If**(** Mod**(** N Rows**(** dt **)**, N Items**(** labels **)** **)**,

labels**[****1** :: Mod**(** N Rows**(** dt **)**, N Items**(** labels **)** **)]**,

**{}**

**)**

**)**

**)**

**)**;

4 REPLIES 4

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Set Row Values as Character Sequence

I found one simple workaround. Set values using Sequence and then change these values to the desired character string using Value Labels.

/*

bigClass = Open( "$SAMPLE_DATA/Big Class.JMP" );

bigClass << New Column( "Char Sequence",

Character,

Nominal,

Format( "Best", 9 ),

Formula( Sequence( 1, 3, 1, 1 ) ),

Value Labels( {1 = "a", 2 = "b", 3 = "c"} ),

Use Value Labels( 1 )

);

*/

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Clever workaround!

Here's another way I've used that may be more general and not requiring a formula (but there "should" be a simpler way..):

dt = Open**(** "$SAMPLE_DATA/Big Class.JMP" **)**;

labels = **{**"a", "b", "c"**}**; // could be any sequence

dt << New Column**(** "Char Sequence2",

Character,

Nominal,

Values**(**

Insert**(**

Repeat**(** labels, N Rows**(** dt **)** / N Items**(** labels **)** **)**,

If**(** Mod**(** N Rows**(** dt **)**, N Items**(** labels **)** **)**,

labels**[****1** :: Mod**(** N Rows**(** dt **)**, N Items**(** labels **)** **)]**,

**{}**

**)**

**)**

**)**

**)**;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Set Row Values as Character Sequence

Thanks MS.

Yes, it seems there is no simple answer for this one.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Set Row Values as Character Sequence

Facing this problem myself today I found this post. It did give me a few logic ideas. Below is a slightly more condensed technique.

dt = Open( "$SAMPLE_DATA/Big Class.JMP" ); labels = {"a", "b", "c"}; // could be any sequence dt << New Column( "Char Sequence2", Character, Nominal, Set Each Value(labels[1 + Mod( Row() - 1, n items(labels) )]) );

Indeed I had hoped for sequence to function on character as well. But at least leveraging set each value you can simplify the flow.