cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • JMP will suspend normal business operations for our Winter Holiday beginning on Wednesday, Dec. 24, 2025, at 5:00 p.m. ET (2:00 p.m. ET for JMP Accounts Receivable).
    Regular business hours will resume at 9:00 a.m. EST on Friday, Jan. 2, 2026.
  • We’re retiring the File Exchange at the end of this year. The JMP Marketplace is now your destination for add-ins and extensions.

Discussions

Solve problems, and share tips and tricks with other JMP users.
%3CLINGO-SUB%20id%3D%22lingo-sub-717324%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EComment%20stocker%20correctement%20les%20valeurs%20des%20variables%20dans%20une%20liste%20%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-717324%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3ELes%206%20premi%C3%A8res%20lignes%20du%20script%20ci-dessous%20fonctionnent%20comme%20pr%C3%A9vu%2C%20avec%20le%20r%C3%A9sultat%20copi%C3%A9%20ci-dessous.%3C%2FP%3E%3CP%3EEnsuite%2C%20j'ai%20essay%C3%A9%20de%20stocker%20les%20valeurs%20de%20ces%20variables%20dans%20une%20liste%2C%20ce%20qui%20n'a%20pas%20fonctionn%C3%A9.%20Il%20semble%20que%20les%20noms%20de%20variables%20au%20lieu%20des%20valeurs%20aient%20%C3%A9t%C3%A9%20stock%C3%A9s.%20Comment%20stocker%20les%20valeurs%20des%20variables%20dans%20la%20liste%20%3F%20Merci!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Edt%20%3D%20new%20table(%22my%20table%22%2C%20new%20column(%22X%22%2C%20set%20values(%7B-0.35%2C%200.15%2C%200.3%7D)%20)%20)%3B%0Adt%20%26lt%3B%26lt%3B%20new%20column(%22Y%22%2C%20set%20values(%7B300%2C%20250%2C%20200%7D)%20)%3B%0Axmean%20%3D%20col%20mean%20(%3AX)%3B%0Aymax%20%3D%20col%20max(%3AY)%3B%0Aymin%20%3D%20col%20min(%3AY)%3B%0Aprint%20(xmean%2C%20ymax%2C%20ymin)%3B%0A%0Adtsum%20%3D%20%7Bxmean%2C%20ymax%2C%20ymin%7D%3B%0Aprint%20(dtsum)%3B%0Aif%20(dtsum%5B1%5D%20%26lt%3B%200%2C%20print%20(dtsum%5B2%5D)%2C%20print(dtsum%5B3%5D))%3B%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ELes%20sorties%3A%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3E0.0333333333333333%0A300%0A200%0A%7Bxmean%2C%20ymax%2C%20ymin%7D%0A.%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-717324%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CLINGO-LABEL%3EAutomatisation%20et%20scripts%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-717337%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%20%3A%20Comment%20stocker%20correctement%20les%20valeurs%20des%20variables%20dans%20une%20liste%20%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-717337%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EUtilisez%20Eval%20List()%20pour%20%C3%A9valuer%20la%20liste%20(%3CA%20href%3D%22https%3A%2F%2Fwww.jmp.com%2Fsupport%2Fhelp%2Fen%2F17.2%2F%23page%2Fjmp%2Fevaluate-lists.shtml%23%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%20Guide%20de%20script%20%26gt%3B%20Structures%20de%20donn%C3%A9es%20%26gt%3B%20Listes%20dans%20les%20scripts%20JSL%20%26gt%3B%20%C3%89valuer%20les%20listes%3C%2FA%3E%20)%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20To%20Here(1)%3B%0A%0Adt%20%3D%20New%20Table(%22my%20table%22%2C%20New%20Column(%22X%22%2C%20set%20values(%7B-0.35%2C%200.15%2C%200.3%7D)))%3B%0Adt%20%26lt%3B%26lt%3B%20New%20Column(%22Y%22%2C%20set%20values(%7B300%2C%20250%2C%20200%7D))%3B%0Axmean%20%3D%20Col%20Mean(%3AX)%3B%0Aymax%20%3D%20Col%20Max(%3AY)%3B%0Aymin%20%3D%20Col%20Min(%3AY)%3B%0APrint(xmean%2C%20ymax%2C%20ymin)%3B%0A%0Adtsum%20%3D%20Eval%20List(%7Bxmean%2C%20ymax%2C%20ymin%7D)%3B%0A%0APrint(dtsum)%3B%0AIf(dtsum%5B1%5D%20%26lt%3B%200%2C%0A%20Print(dtsum%5B2%5D)%2C%0A%20Print(dtsum%5B3%5D)%0A)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-717348%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%20%3A%20Comment%20stocker%20correctement%20les%20valeurs%20des%20variables%20dans%20une%20liste%20%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-717348%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EMerci!%3C%2FP%3E%3C%2FLINGO-BODY%3E
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!

Recommended Articles