In the process of data analysis, sometimes we often need to combine multiple columns of indicators into one column, such as converting a 100-column 5-column data table generated by 100 persons and 5 observation time points into a 500-column 1-column data table. So as to meet the further needs of drawing and analysis. So, how to implement it quickly in JMP? Today in this article we will introduce: how to merge and process multiple columns of data in JMP.
When analyzing data, we often encounter this situation: a person has multiple main analysis indicators at the same time (such as multiple time points in the follow-up data). When importing data, they are usually imported in different Columns (such as 5 time point data, imported in 5 columns). Although this kind of import seems intuitive, it is sometimes necessary to place these columns in the same column during analysis.
If only 5 columns are good, copying them one by one will not take much time. But what if it is 20 columns or more? Not only is it time-consuming and laborious, but copying and pasting is also prone to errors. Today we are going to understand how the "stacking" in data cleaning can quickly merge multiple columns into one column, and at the same time add an identification variable to display different indicators.
Below we use the demonstration data that comes with JMP to demonstrate how to implement data stacking. You can click on the top menu "Help "--> " Sample Data Library Find the demo data in ", as shown in Figure 1 below

Figure 1: JMP help file and demonstration data
This time, as an example, we will use the Blood Pressure.jmp data file in the sample database. The overall situation of the data is shown in Figure 2.

Figure 2 Demonstration data
The 20 subjects were divided into four groups. The variable BP 8M means the blood pressure measurement value at 8 o'clock on Monday. Therefore, the data records the blood pressure measurement values of each subject at three different time points each day on Monday, Wednesday, and Friday. That's right, this is standard repeated measurement data, and many doctors collect data in this format in clinical practice.
first step: Stack multi-column indicators into one column indicator
First, imagine a situation like this. After obtaining the data, you want to compare whether the blood pressure measurement values of the four groups of subjects are different. At this time, the blood pressure measurement value becomes the dependent variable y, and the measurement time point and grouping become the independent variable x1 And x2, the current data format, obviously does not meet the requirements of our next analysis.
We need to stack the columns of 9 time points into two columns, one column of time points and the other column of measured values, and one-to-one correspondence. How to operate in JMP? Just one step!

Figure 3-In the menu "Tables "Select " Stack ", a stacked dialog box will appear
- Stack columns – Choose the column you want to stack
- Output table name – Enter the stacked table name
- Stacked Data Column / Source Label Column- Since we will form two new variables after stacking, one is the time point (source label column), and the other is the blood pressure measurement value (stacked data column), we can set variable names for them separately, if not modified, then the new variable Will use the system default [ Data 】with【 Label ] As the variable name;
The operation process is shown in Figure 4:

Figure 4-Demonstration of column stacking operation process
Therefore, the newly generated data table is shown in Figure 5:

Figure 5-A new data table is generated after the columns are stacked
The 20 subjects each measured the blood pressure values at 9 time points, so the newly generated data table has 180 observations, and the labels and data are the time points and blood pressure values before stacking. In this way, we can proceed to the follow-up analysis.
Step 2: Stack multi-column indicators into multi-column indicators
For different analysis purposes, you may be thinking: the operation is the same as before.
However, the difference is the need for analysis purposes

Figure 6-Multi-sequence column stacking
Because here is the continuous three-column variables stacked into one column, and a total of three columns are stacked, so we write the number of ordinal columns as 3, check "Continuous", and click OK, as shown in Figure 7:

Figure 7
The generated data table is shown in Figure 8. The daily data of each subject is a column:

Figure 8
In daily data sorting and summarization, in addition to stacking multiple columns into one column, there are also situations in which one column is split into multiple columns. We will introduce to you the reverse operation of "stacking" in a later article-split, that is, what is the meaning of split? What are the precautions? Stay tuned for the follow-up# ANALYSE information 10 Skills column!
Original link: The "stacking" of data cleaning-an artifact of multi-column data merging processing
Recommended reading:
Note: This article is the fifth issue of this series of articles. Click on #Data analysis10 Skill To review other articles.