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.
Choose Language Hide Translation Bar
Robbb
Level III

How to stack a variable number of series?

The following code does not work, but it does when replacing "n_series" with 3 in the Stack command.

dt = Open( "$SAMPLE_DATA/Blood Pressure.jmp" );
n_series = 3;
dt << Stack(
	columns(:BP 8M, :BP 12M, :BP 6M, :BP 8W, :BP 12W, :BP 6W, :BP 8F, :BP 12F, :BP 6F),
	Number of Series( n_series ),
	Contiguous,
	Source Label Column( "Day" ),
	Stacked Data Column( "BP" )
);

I need to have this value variable. How to get Stack() running with a variable number of series?

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: How to stack a variable number of series?

In this case you can try using Eval()

Names Default To Here(1);

n_series = 3;

dt = Open("$SAMPLE_DATA/Blood Pressure.jmp");

dt_stacked = dt << Stack(
	columns(:BP 8M, :BP 12M, :BP 6M, :BP 8W, :BP 12W, :BP 6W, :BP 8F, :BP 12F, :BP 6F),
	Number of Series(Eval(n_series)),
	Contiguous,
	Source Label Column("Day"),
	Stacked Data Column("BP")
);

More general solution is to evaluate the value inside the expression

Names Default To Here(1);

n_series = 3;

dt = Open("$SAMPLE_DATA/Blood Pressure.jmp");

dt_stacked = Eval(EvalExpr(dt << Stack(
	columns(:BP 8M, :BP 12M, :BP 6M, :BP 8W, :BP 12W, :BP 6W, :BP 8F, :BP 12F, :BP 6F),
	Number of Series(Expr(n_series)),
	Contiguous,
	Source Label Column("Day"),
	Stacked Data Column("BP")
)));

 

 

-Jarmo

View solution in original post

1 REPLY 1
jthi
Super User

Re: How to stack a variable number of series?

In this case you can try using Eval()

Names Default To Here(1);

n_series = 3;

dt = Open("$SAMPLE_DATA/Blood Pressure.jmp");

dt_stacked = dt << Stack(
	columns(:BP 8M, :BP 12M, :BP 6M, :BP 8W, :BP 12W, :BP 6W, :BP 8F, :BP 12F, :BP 6F),
	Number of Series(Eval(n_series)),
	Contiguous,
	Source Label Column("Day"),
	Stacked Data Column("BP")
);

More general solution is to evaluate the value inside the expression

Names Default To Here(1);

n_series = 3;

dt = Open("$SAMPLE_DATA/Blood Pressure.jmp");

dt_stacked = Eval(EvalExpr(dt << Stack(
	columns(:BP 8M, :BP 12M, :BP 6M, :BP 8W, :BP 12W, :BP 6W, :BP 8F, :BP 12F, :BP 6F),
	Number of Series(Expr(n_series)),
	Contiguous,
	Source Label Column("Day"),
	Stacked Data Column("BP")
)));

 

 

-Jarmo

Recommended Articles