I was disappointed to find out that JMP resricts us from stacking just one column. I understand that stacking just one column doesn't make sense, however, since it's just a data transform it does make sense to want to do it.
Anyways, I wanted to open up the conversation and see who can come up with a better work around than I did. Here's mine:
Names Default to Here(1);
//Example Data Table
dt = Open( "$SAMPLE_DATA/Decathlon.jmp" );
//col list is list of columns from 1 to n (never an empty list)
colList = {"Javelin", "Pole Vault"};
//Stack columns to prepare data for analysis
if(nitems(colList) > 1,
analysisColsExpr = Expr(columns());
for(i=1; imax=nitems(colList), i<=imax, i++,
col = Column(dt, colList[i]);
insert into(analysisColsExpr, col);
);
dtAnalysis = Eval(Eval Expr(dt << Stack(
Expr( Name Expr( analysisColsExpr )),
Source Label Column( "AnalysisType" ),
Stacked Data Column( "AnalysisValue" ),
Output Table( "Stacked Data" )
)));
close(dt, nosave);
,
//Can't stack only one column adjust columns to match above strategy
dt << New Column("AnalysisType", Character, Nominal, Formula(colList[1]));
column(dt, colList[1]) << Set Name("AnalysisValue");
dt << Set Name("Stacked Data");
dtAnalysis = dt;
);
//Run Analysis
oneway = dtAnalysis << Oneway( Y( :AnalysisValue ), X( :AnalysisType ) );
Good Luck!