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

- JMP User Community
- :
- Discussions
- :
- Possible to create x number of lists, where x is the number of loops in For stat...

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

Highlighted

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

Aug 29, 2019 5:38 AM
(1137 views)

Is there anyway to script in creating a variable number of lists depending on the number of loops in a for statement? I was thinking something like below would work, but no luck.

```
xyz = N Items( List1 );
NumOfSets = Divide To( xyz, 4 );
For( i = 1, i <= NumOfSets, i++,
List( Concat( Set, Char( [i] ) ) )
);
```

1 ACCEPTED SOLUTION

Accepted Solutions

Highlighted

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

Something like this? I'm creating a list of lists.

```
list1 = {"aaa", "bbb", "ccc", "ddd", "eee", "fff", "ggg", "hhh"};
xyz = N Items( List1 );
NumOfSets = Divide To( xyz, 4 );
list_array = {};
set = "xyz";
For( i = 1, i <= NumOfSets, i++,
list_array[i] = eval list(list( Concat( Set, Char(i) )));
);
list_array;
```

2 REPLIES 2

Highlighted

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

Something like this? I'm creating a list of lists.

```
list1 = {"aaa", "bbb", "ccc", "ddd", "eee", "fff", "ggg", "hhh"};
xyz = N Items( List1 );
NumOfSets = Divide To( xyz, 4 );
list_array = {};
set = "xyz";
For( i = 1, i <= NumOfSets, i++,
list_array[i] = eval list(list( Concat( Set, Char(i) )));
);
list_array;
```

Highlighted
##

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

Re: Possible to create x number of lists, where x is the number of loops in For statement?

Yes, it looks like that will do the trick. Thank you

Article Labels

There are no labels assigned to this post.