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
- :
- Discussions
- :
- Re: how do l use the value from another variable as the first value then add 3.3...

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

Aug 7, 2019 6:34 PM
(229 views)

Hi,

Was wondering if anyone can help me with a syntax problem, l wish to use the first value from another variable then increase this value by 3.3, the same as the below,

Obs | Expected | |

12.3 | 12.3 | |

15.4 | 15.6 | |

18.7 | 18.9 | |

22.0 | 22.2 | |

25.8 | 25.5 | |

28.9 | 28.8 | |

32.2 | 32.1 | |

35.1 | 35.4 |

Currently I have set the values as follows, however I would really like to automate as l have a few to do

```
Acc << New Column( "exp",
Numeric,
Continuous,
Format( "fixed dec", 6, 1 ),
Set Selected,
Set Values( [12.3, 15.6, 18.9, 22.2, 25.5, 28.8, 32.1, 35.4] )
);
```

Thanks to all

2 ACCEPTED SOLUTIONS

Accepted Solutions

Highlighted

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

Here are a couple of ways to do what you outlined in your last response

```
New Table( "Example",
Add Rows( 8 ),
New Column( "Obs",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [12.3, 15.4, 18.7, 22, 25.8, 28.9, 32.2, 35.1] )
),
New Column( "exp1",
Numeric,
"Continuous",
Format( "Best", 12 ),
Formula(
If( Row() == 1,
start = :Obs,
start = start + 3.3
);
start;
)
),
New Column( "exp2",
Numeric,
"Continuous",
Format( "Best", 12 ),
Formula( :Obs[1] + (Row() - 1) * 3.3 )
)
);
```

Jim

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

so, this simple formula might work.

Sounds like you want the result to be lag one cell plus a constant.

like this?

Lag(:Expected) + 3.3

JMP Systems Engineer, Pharm and BioPharm Sciences

6 REPLIES 6

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

Re: how do l use the value from another variable as the first value then add 3.3 for each thereafter

You need to take the time to read the documentation on JSL.

Help==>Books==>Scripting Guide

The way to do this is a very simple formula

`ACC << New Column( "exp", formula( :Obs +3.3 ) );`

Jim

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

Re: how do l use the value from another variable as the first value then add 3.3 for each thereafter

Sorry, l may have confused you, the first value of "exp" equals "obs", then i would like to add 3.3 to the prior value of "exp", so in this case, the first value of "exp" is equal to 12.3, then add 3.3 to this value for the second value of "exp" = 15.6, the third = 18.9, so the first value of "exp" is dependent on "obs" but none of the other values are, your "very simple formula" will not achive this.

- Tags:
- Not the solution

Highlighted

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

Here are a couple of ways to do what you outlined in your last response

```
New Table( "Example",
Add Rows( 8 ),
New Column( "Obs",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [12.3, 15.4, 18.7, 22, 25.8, 28.9, 32.2, 35.1] )
),
New Column( "exp1",
Numeric,
"Continuous",
Format( "Best", 12 ),
Formula(
If( Row() == 1,
start = :Obs,
start = start + 3.3
);
start;
)
),
New Column( "exp2",
Numeric,
"Continuous",
Format( "Best", 12 ),
Formula( :Obs[1] + (Row() - 1) * 3.3 )
)
);
```

Jim

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

Re: how do l use the value from another variable as the first value then add 3.3 for each thereafter

Thanks so much, worked a treat

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

so, this simple formula might work.

Sounds like you want the result to be lag one cell plus a constant.

like this?

Lag(:Expected) + 3.3

JMP Systems Engineer, Pharm and BioPharm Sciences

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

Re: how do l use the value from another variable as the first value then add 3.3 for each thereafter

Thanks very much