cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • JMP 19 is here! See the new features at jmp.com/new.
  • Register to attend Discovery Summit 2025 Online: Early Users Edition, Sept. 24-25.
Choose Language Hide Translation Bar
SpannerHead
Level VI

Using numeric objects in a column equation

I need to be able to take a numeric object that increases or decreases in an iterative function and use it in a column formula.  In the equation below, the values of col, l and m need to be evaluated in the column formula.  How can I get this to happen?  Parse(), Eval() and Num() aren't working.

 

	For( i = 1, i <=8, i++,
	col = 11+i;
	l = col - i;
	m = col + 1 - i; 
	colno = Char(col);
	 New Column("Column "||colno, Character, "Nominal", Formula(If(Row() == 12, Lag(Column(1), l), If(Row() == 13, Lag(Column(2), m), Lag(Column(col, 1)))))));

Slán



SpannerHead
5 REPLIES 5

Re: Using numeric objects in a column equation

This seems to work.  Eval( Eval Expr(....) ) evaluates the expressions before creating the column.

 

For( i = 1, i <= 8, i++,
	col = 11 + i;
	l = col - i;
	m = col + 1 - i;
	colno = Char( col );
	Eval(
		Eval Expr(
			New Column( "Column " || Expr( colno ),
				Character,
				"Nominal",
				Formula(
					If( Row() == 12,
						Lag( Column( 1 ), Expr( l ) ),
						If( Row() == 13,
							Lag( Column( 2 ), Expr( m ) ),
							Lag( Column( Expr( col ), 1 ) )
						)
					)
				)
			)
		)
	);
);
hogi
Level XIII

Re: Using numeric objects in a column equation

Column( col, 1 )

?

hogi_0-1758800939329.png

 

hogi
Level XIII

Re: Using numeric objects in a column equation

No variable defined outside of the new column message should be used inside the new column() message.
In my company we have an automatic check that detects such programming issues before executing the code.
If a potential error is detected, a warning message is presented to the user with some suggestions.

 

Re: Expression Handling in JMP: Tipps and Trapdoors 

 

For( i = 1, i <= 8, i++,
	col = 11 + i;
l = col - i; m = col + 1 - i; colno = Char( col ); Eval(Eval Expr(New Column( "Column " || colno, Character, "Nominal", Formula( If( Row() == 12, Lag( Column( 1 ), Expr(l) ), If( Row() == 13, Lag( Column( 2 ), Expr(m) ), Lag( Expr(Name Expr(As Column( col))), 1 ) ) ) ))) ); );

 

ouch! As column doesn't understand numbers ...

hogi
Level XIII

Re: Using numeric objects in a column equation

For( i = 1, i <= 8, i++,
	col = 11 + i;
	colname = Column(col) << get name;
	l = col - i;
	m = col + 1 - i;
	colno = Char( col );
	Eval(Eval Expr(New Column( "Column " || colno,
		Character,
		"Nominal",
		Formula(
			If( Row() == 12,
				Lag( Column( 1 ), Expr(l) ),
				If( Row() == 13,
					Lag( Column( 2 ), Expr(m) ),
					Lag( Expr(Name Expr(As Column( colname))), 1 )
				)
			)
		)))
	);
);

Re: Using numeric objects in a column equation

Good catch.

Recommended Articles