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
- :
- Setting values to a cell

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

Aug 28, 2016 11:33 PM
(1202 views)

Hello all,

It's been some time since I did any programming in JSL, so I'll be asking some basics questions which I did not find in the manuals.

1. How, using a JSL, I can set a specific value to a specific Col/Row?

2. I need to do that in a For loop. Let's say I need to run a loop from 1 to number of rows, and assign (for now) the same number to each Row of a Specific column. How do I do that this way?

3. Specific example. I have M sets of N measurements. I have datetime for each measurement. I know that each *m*th measurement was done in order. But do not have column that says what set it is, I only have column that has the measurement.

In other words I have only first column, and I need to make the second.

I know how to do the logic - See the difference between current row and the previous one, and as soon as it's not 1, iterate the MeasSet counter.

But how do I iterate and how do I write this FOR loop?

I wrote it once, but lost the code and starting from the beginning here.

Counter1 | MeasSet |
---|---|

1 | 1 |

2 | 1 |

3 | 1 |

4 | 1 |

5 | 1 |

1 | 2 |

2 | 2 |

3 | 2 |

4 | 2 |

5 | 2 |

1 ACCEPTED SOLUTION

Accepted Solutions

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

Solution

Here are some examples that may give you an idea:

dt = Current Data Table**()**;

// 1. With a column variable

col = Column**(**dt, "MeasSet"**)**;

col**[****6****]** = **2**;

// or directly

// "dt" in Column() is optional but good if same column name occurs in other open tables

Column**(**dt, "MeasSet"**)[****1****]** = **1**;

// 2.

For Each Row**(**col**[]** = **1****)**;

// 3.

For**(**i = **1**, i <= N Rows**(**dt**)**, i++,

If**(**:Counter1**[**i**]** == **1**,

col**[**i**]** = set = **1**,

col**[**i**]** = set

**)**;

set++;

**)**;

2 REPLIES

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

Here are some examples that may give you an idea:

dt = Current Data Table**()**;

// 1. With a column variable

col = Column**(**dt, "MeasSet"**)**;

col**[****6****]** = **2**;

// or directly

// "dt" in Column() is optional but good if same column name occurs in other open tables

Column**(**dt, "MeasSet"**)[****1****]** = **1**;

// 2.

For Each Row**(**col**[]** = **1****)**;

// 3.

For**(**i = **1**, i <= N Rows**(**dt**)**, i++,

If**(**:Counter1**[**i**]** == **1**,

col**[**i**]** = set = **1**,

col**[**i**]** = set

**)**;

set++;

**)**;

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

Aug 29, 2016 7:04 AM
(1146 views)

Thanks,

I came up with this solution:

i=**1**;

For Each Row**(**

If **((**:Counter1 - lag**(**:Counter1**))**!=**1**, **(**i++; :MeasSet=i**)** , **(**i=i; :MeasSet=i**)**, **(**:MeasSet=i**)** **)**;

**)**;

I need to stress two things:

1. Needs to be !=, not ==

2. Had to put i=i, otherwise script asks if I want to use comparison "==" or assign value "=" for next MeasSet.