Sometimes, we may need to format the data differently for a specific analysis or break it down for further analysis.
The Format Data tool can primarily be used to quickly stack and unstack columns to change the way the data has been formatted.
The stacking of columns means that data has been collected in separate columns, which must be stacked on each other. The stacking of columns will always result in all the column data getting merged into one column, and the subscripts for this data are the column's names. On the other hand, the unstacking of columns is taking data in a single column and using the subscript to unstack this data into multiple columns.
This tool can also code the inputs when generating the outputs. For example, we can code "No" to 0 and "Yes" to 1. So, if any of the input columns contain the value "No," then a value of 0 would be written when generating the output. Coding applies to all columns; any value on the input side is coded regardless of the column.
You may also specify how to handle any missing or blank values during the stacking and unstacking operation. You may ignore the missing values, which will cause any missing values to remain in the output. You can delete only that particular missing value but retain the remaining values. You should be careful with this option, especially if you have cross-sectional data. Finally, you can delete the entire row if any value is missing in any column. This option works well for cross-sectional data but may reduce the size of your data for subsequent analysis.
Analysis Setup
Click on Analysis Setup to open the menu options for this tool.
Setup
A sample screenshot of the setup menu is shown below.
1
Stack Columns:
Specify if you want to stack or unstack your input data.
Option
Description
Stack
Stacking the data means converting data that is stored in multiple columns into two columns so that one column has the group number and the second column has your data points.
Transpose & Stack
Stacking the data means converting data that is stored in multiple columns into two columns so that one column has the group number and the second column has your data points. In this case, the data is first transposed before it is stacked. This may be useful if you are trying to keep all subgroups together, for example, when you collect subgroup data in columns and want to stack the data for analysis.
Unstack
Unstacking is the reverse process where the data is covered from grouped format to individual columns.
No Change
If you specify no change, then the original data formatting is preserved.
2
Missing Values:
Specify how you want to handle missing values in your original data set.
Option
Description
No Change
Ignore the missing values in the data. The output format will also contain these missing values.
Delete Rows
Delete the entire row if any one of the input rows has missing values. Each row is treated as one related set.
Delete Values
Delete only those values that are missing and retain the remaining values that are not missing. Note that each row is not treated as one set.
3
Help Button:
Click on this button to open the help file for this topic.
4
Cancel Button:
Click on this button to cancel all changes to the settings and exit this dialog box.
5
OK Button:
Click on this button to save all changes and compute the outputs for this analysis.
Data
You will see the following dialog box if you click the Data button. Here, you can specify the data required for this analysis.
1
Search Data:
The available data displays all the columns of data that are available for analysis. You can use the search bar to filter this list and speed up the search for the right data for analysis. Enter a few characters in the search field, and the software will filter and display the filtered data in the Available Data box.
2
Available Data:
The available data box contains the list of data available for analysis. If your workbook has no data in tabular format, this box will display "No Data Found." The information displayed in this box includes the row number, whether the data is Numeric (N) or Text (T), and the name of the column variable. Note that the software displays data from all the tables in the current workbook. Even though data within the same table have unique column names, columns across different tables can have similar names. Hence, it is crucial that you not only specify the column name but also the table name.
3
Add or View Data:
Click on this button to add more data to your workbook for analysis or to view more details about the data listed in the available data box. When you click on this button, it opens the Data Editor dialog box, where you can import more data into your workbook. You can also switch from the list view to a table view to see the individual data values for each column.
4
Required Data:
The code for the required data specifies what data can be specified for that box. An example code is N: 2-4. If the code starts with an N, you must select only numeric columns. If the code begins with a T, you can select numeric and text columns. The numbers to the right of the colon specify the min-max values. For example, if the min-max values are 2-4, you must select a minimum of 2 columns of data and a maximum of 4 columns in this box. If the minimum value is 0, then no data is required to be specified for this box.
5
Select Button:
Click on this button to select the data for analysis. Any data you choose for the analysis is moved to the right. To select a column, click on the columns in the Available Databox to highlight them and then click on the Select Button. A second method to choose the data is to double-click on the columns in the list of Available Data. Finally, you can drag and drop the columns you are interested in by holding down the select columns using your left mouse key and dragging and dropping them in one of the boxes on the right.
6
Selected Data:
The list box header will be displayed in black if the right number of data columns is specified. If sufficient data has not been specified, then the list box header will be displayed in red color. Note that you can double-click on any of the columns in this box to remove them from the box.
The data you specify for this analysis depends on the options in the Setup tab.
Option
Description
1
If Stack Columns is set to Stack Data, then you need to specify the columns that you want to stack under Analysis Variables. The Grouping Variables is disabled.
2
If Stack Columns is set to Unstack Data, then you need to specify your data column under Analysis Variables and the column that contains group information under Grouping Variables.
7
View Selection:
Click on this button to view the data specified for this analysis. The data can be viewed in a tabular format or a graphical summary.
Code Values
A sample screenshot of the code values menu is shown below.
Specify if you want to code the values. Coding is the process of replacing one value with another. You need to specify the From-To pairs for the coding to work. The same coding is applied across all columns.
1
Old Values:
If you have specified the option to code values on Page 1 of the input dialog box, you can specify how you want to code the values on this page. Specify the old values in the first column. Every occurrence of the old values is replaced with the new values in your input data columns.
2
New Values:
Specify the new values here. The old values will be replaced by the new values you specify here.
Verify
If you click the Verify button, the software will perform some checks on the data you entered. A sample screenshot of the dialog box is shown in the figure below.
The software checks if you have correctly specified the input options and entered the required data on the worksheet. The results of the analysis checks are listed on the right. If the checks are passed, they are shown as green-colored checkmarks. If the verification checks fail, they are shown as a red-colored cross. If the verification checks result in a warning, they are shown in the orange exclamation mark, and finally, any checks that are required to be performed by the user are shown as blue info icons.
1
Item:
The left-hand side shows the major tabs and the items checked within each section
2
Status:
The right-hand side shows the status of the checks.
3
Overall Status:
The overall status of all the checks for the given analysis is shown here. The overall status check shows a green thumps-up sign if everything is okay and a red thumps-down sign if any checks have not passed. Note that you cannot proceed with generating analysis results for some analyses if the overall status is not okay.
Outputs
Click on Compute Outputs to update the output calculations. A sample screenshot of the worksheet is shown below. Check the outputs to ensure the transformation is what you expect; if not, make appropriate changes and click on Compute Outputs.
There are no analysis outputs or graphs for this analysis. The data entered in the input columns are reformatted and displayed in the outputs area.
Notes
Here are a few pointers regarding this analysis:
You can manipulate up to 20 variables on the input side using this tool.
The unstack option requires that all the data be stored in 2 columns (subscript and data). Note that you will only see this option when you select the number of input variables as 2.
Examples
The following examples are in the Examples folder.
For the data given in the reference file, stack and unstack the requested columns. (Format Data 1.xlsx).