cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • JMP will suspend normal business operations for our Winter Holiday beginning on Wednesday, Dec. 24, 2025, at 5:00 p.m. ET (2:00 p.m. ET for JMP Accounts Receivable).
    Regular business hours will resume at 9:00 a.m. ET on Friday, Jan. 2, 2026.
  • We’re retiring the File Exchange at the end of this year. The JMP Marketplace is now your destination for add-ins and extensions.

Discussions

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

How to use JSL to repeat a sequence to the end of a data table?

I have a set sequence that I want to repeat to the end of a data table like you can do with the "Fill to End of Column" when you select rows where this can go on for an unspecified number of rows

 

I'm using the following:

 

NewColumn("Part", Character, Values({"1-B","1-B","1-B","1-D","1-D","1-D",
  "1-F","1-F","1-F","1-H","1-H","1-H","1-J","1-J","1-J","1-L","1-L","1-L",
  "2-B","2-B","2-B","2-D","2-D","2-D",
  "2-F","2-F","2-F","2-H","2-H","2-H","2-J","2-J","2-J","2-L","2-L","2-L"}
));

 

1 ACCEPTED SOLUTION

Accepted Solutions
ms
Super User (Alumni) ms
Super User (Alumni)

Re: Fill to end of column in script

Try Repeat().

 

Two examples:

 

seq = {"1-B", "1-B", "1-B", "1-D", "1-D", "1-D", "1-F", "1-F", "1-F", "1-H", "1-H", "1-H", "1-J", "1-J", "1-J",
"1-L", "1-L", "1-L", "2-B", "2-B", "2-B", "2-D", "2-D", "2-D", "2-F", "2-F", "2-F", "2-H", "2-H", "2-H", "2-J",
"2-J", "2-J", "2-L", "2-L", "2-L"};
// Repeat sequence a predefined number of times
New Table( "example 2", New Column( "Part", Character, Values( Repeat( seq, 5 ) ) ) );
// Repeat sequence to fit an existing table
dt = New Table( "example", <<add rows( 400 ) );
dt << New Column( "Part",
  Character,
  Values(
  Repeat( seq, Floor( N Rows( dt ) / N Items( seq ) ) ) || seq[1 :: Mod( N Rows( dt ), N Items( seq ) )]
  )
);

 

View solution in original post

1 REPLY 1
ms
Super User (Alumni) ms
Super User (Alumni)

Re: Fill to end of column in script

Try Repeat().

 

Two examples:

 

seq = {"1-B", "1-B", "1-B", "1-D", "1-D", "1-D", "1-F", "1-F", "1-F", "1-H", "1-H", "1-H", "1-J", "1-J", "1-J",
"1-L", "1-L", "1-L", "2-B", "2-B", "2-B", "2-D", "2-D", "2-D", "2-F", "2-F", "2-F", "2-H", "2-H", "2-H", "2-J",
"2-J", "2-J", "2-L", "2-L", "2-L"};
// Repeat sequence a predefined number of times
New Table( "example 2", New Column( "Part", Character, Values( Repeat( seq, 5 ) ) ) );
// Repeat sequence to fit an existing table
dt = New Table( "example", <<add rows( 400 ) );
dt << New Column( "Part",
  Character,
  Values(
  Repeat( seq, Floor( N Rows( dt ) / N Items( seq ) ) ) || seq[1 :: Mod( N Rows( dt ), N Items( seq ) )]
  )
);

 

Recommended Articles