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

How to store variable values in a list properly?

The first 6 lines of the script below work as I expected, with output copied below.

Then I tried to store the values of these variables in a list, which didn't go well. It appears that the variable names instead of the values were stored. How do I store the variable values in the list? Thank you!

 

 

dt = new table("my table", new column("X", set values({-0.35, 0.15, 0.3}) ) );
dt << new column("Y", set values({300, 250, 200}) );
xmean = col mean (:X);
ymax = col max(:Y);
ymin = col min(:Y);
print (xmean, ymax, ymin);

dtsum = {xmean, ymax, ymin};
print (dtsum);
if (dtsum[1] < 0, print (dtsum[2]), print(dtsum[3]));

 

Outputs:

0.0333333333333333
300
200
{xmean, ymax, ymin}
.

 

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: How to store variable values in a list properly?

Use Eval List() to evaluate the list ( Scripting Guide > Data Structures > Lists in JSL Scripts > Evaluate Lists )

Names Default To Here(1);

dt = New Table("my table", New Column("X", set values({-0.35, 0.15, 0.3})));
dt << New Column("Y", set values({300, 250, 200}));
xmean = Col Mean(:X);
ymax = Col Max(:Y);
ymin = Col Min(:Y);
Print(xmean, ymax, ymin);

dtsum = Eval List({xmean, ymax, ymin});

Print(dtsum);
If(dtsum[1] < 0,
	Print(dtsum[2]),
	Print(dtsum[3])
);
-Jarmo

View solution in original post

2 REPLIES 2
jthi
Super User

Re: How to store variable values in a list properly?

Use Eval List() to evaluate the list ( Scripting Guide > Data Structures > Lists in JSL Scripts > Evaluate Lists )

Names Default To Here(1);

dt = New Table("my table", New Column("X", set values({-0.35, 0.15, 0.3})));
dt << New Column("Y", set values({300, 250, 200}));
xmean = Col Mean(:X);
ymax = Col Max(:Y);
ymin = Col Min(:Y);
Print(xmean, ymax, ymin);

dtsum = Eval List({xmean, ymax, ymin});

Print(dtsum);
If(dtsum[1] < 0,
	Print(dtsum[2]),
	Print(dtsum[3])
);
-Jarmo

Re: How to store variable values in a list properly?

Thanks!