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
rmeredith
Level I

Using variables to create formula columns

For( i = 1, i <= N Items( allm ), i++,
	m = allm[i];
	name = "Peak Mass " || Char( m );
	del = Current Data Table() << delete columns( Char( name ) );
	(New Column( Char( name ), set formula( If( subtract(eval(m), 3) < :deltamass <= add(eval(m),3), :pctrelative, 0 ) ) ) ; 
	If( Contains( name, "Peak Mass 0" ),
		del
	) ; );
);

Help! I have tried like 5 things, and I can't get my variable to spit out it's numerical value into the column formula. 

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Using variables to create formula columns

Most likely something like this:

	Eval(EvalExpr(New Column(Char(name), set formula(If(Subtract(Expr(m), 3) < :deltamass <= Add(Expr(m), 3), :pctrelative, 0))));

Wrap New Column() with Eval(EvalExpr()) and replace Eval with Expr() inside it.

-Jarmo

View solution in original post

3 REPLIES 3
jthi
Super User

Re: Using variables to create formula columns

Eval(EvalExpr()) should do the trick

-Jarmo
rmeredith
Level I

Re: Using variables to create formula columns

Just suck in where I currently have eval(m)? I just tried that and it is still just putting "Eval Expr(eval(m))" into the column function rather than the numerical value of m. 

jthi
Super User

Re: Using variables to create formula columns

Most likely something like this:

	Eval(EvalExpr(New Column(Char(name), set formula(If(Subtract(Expr(m), 3) < :deltamass <= Add(Expr(m), 3), :pctrelative, 0))));

Wrap New Column() with Eval(EvalExpr()) and replace Eval with Expr() inside it.

-Jarmo