cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
Mickyboy
Level V

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

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
txnelson
Super User

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

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

View solution in original post

Byron_JMP
Staff

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

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, Health and Life Sciences (Pharma)

View solution in original post

6 REPLIES 6
txnelson
Super User

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
Mickyboy
Level V

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.
txnelson
Super User

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

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
Mickyboy
Level V

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
Byron_JMP
Staff

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

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, Health and Life Sciences (Pharma)
Mickyboy
Level V

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

Thanks very much