cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar

Stacking Columns

Started ‎11-08-2022 by
Modified ‎11-08-2022 by
View Fullscreen Exit Fullscreen

Sometimes, you might need to combine the values from two or more columns into one column. This is known as stacking columns. The raw might data might be structured in such a way that there's a separate column for each group or category of a variable -- for example, the calories in beef versus poultry hot dogs. In JMP, if you want to compare the average calories of these two groups, you need one column indicating the group, and one column with the calories. You can send the Stack message to a data table to accomplish this. The only required argument is the Columns argument, which specifies the columns from the original data table that you want to combine. Other arguments are optional. The Stacked Data Column argument specifies a name for the new column that will contain the original data values. The Source Label Column argument specifies a name for the new column that will contain the original column headers, indicating which group the observation belongs to. And then the Output Table Name argument specifies a name for the new stacked data table. So the code shown here stacks two columns from the Hot Dogs data table: Beef and Poultry. The new, stacked column will be named Calories. And the new source column will be named Type, and will either have the value Beef or Poultry depending on which original column the row came from. These new columns will be stored in a data table named HD Cals.