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

Showing results for

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

- 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
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Jun 4, 2013 11:51 AM
(2694 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!

Solved! Go to Solution.

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Jun 4, 2013 1:40 PM
(5075 views)

Solution

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Jun 4, 2013 12:55 PM
(2538 views)

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
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Jun 4, 2013 1:40 PM
(5076 views)

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
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Jun 4, 2013 1:46 PM
(2538 views)

Thanks MS.

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Mar 2, 2017 4:29 PM
(2424 views)

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.